0

I created a custom JavaScript GitHub action that needs to run simple git and node commands. I used the exec npm module provided by GitHub.

Every time I try to run a command it fails. For example:

exec.exec('git config user.name "Package Updater"')

fails with

##[error]There was an error when attempting to execute the process '/usr/bin/git'. This may indicate the process failed to start. Error: spawn /usr/bin/git ENOENT

The same thing happens with node or npm commands.

The command above works fine locally if I execute the action's js file with node.

MkMan
  • 1,779
  • 1
  • 14
  • 27
  • 1
    if the commands are either not installed or not in the global path of the runner then these won’t work. Since node actions run directly on the runner. Could you run this commands in steps on your workflow to test if they are installed in the runner? If not, you could trying installing above the action and see if that helps. – Edward Romero Sep 07 '20 at 03:55

1 Answers1

0

Eventually, I realised that error was from npm child process module which is used to execute commands. That led me to investigate how I was calling the function.

I had wrapped the exec function in another function provide a way to capture the output as shown in the official docs. When I removed this wrapping it worked. I must have implemented the options parameter incorrectly.

MkMan
  • 1,779
  • 1
  • 14
  • 27