actions / actions/toolkit

Cannot get output from exec.exec or exec.getExecOutput

Open
#927 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
When executing a command using exec.exec or exec.getExecOutput, I cannot get the output of the command. I can see the command output in live web console, but when printing the output (constructed through listeners.stdout), it's empty. Similarly, the getExecOutput helper function also returns empty output.

async function configure () {
  // Get configurations
  const config = await getConfig()

  const keyFile = 'private.key'
  await fs.promises.writeFile(keyFile, config.gitUserSigningKey)
  const { stdout } = await exec.getExecOutput('gpg', ['--import', keyFile])

  // stdout is empty!
}
async function configure () {
  // Get configurations
  const config = await getConfig()

  let cmdOutput = ''
  const options = {
    listeners: {
      stdout: (data) => { cmdOutput += data.toString() }
    }
  }
 
  const keyFile = 'private.key'
  await fs.promises.writeFile(keyFile, config.gitUserSigningKey)
  await exec.exec('gpg', ['--import', keyFile], options)

  // stdout is empty!
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue through exec.exec and exec.getExecOutput with the gpg command shown, comparing the live console output with listeners.stdout and the returned stdout. Trace how command output is captured and returned; done means both APIs expose the command's stdout consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.