Toolkit: exec doesn't resolve Windows .cmd/.bat files from the PATH

Created on 13 Nov 2019  路  7Comments  路  Source: actions/toolkit

Describe the bug

exec.exec('npm --version') does not work on Windows.

To Reproduce

name: CI
on: [push]
jobs:
  build:
    runs-on: windows-latest
    steps:
      - shell: cmd
        run: |
          echo Verify npm is in the PATH:
          where npm
          echo ----------------------------------------
          echo Invoking "npm --version" works on the command line:
          call npm --version
          echo ----------------------------------------
          echo Installing @actions/exec
          call npm install @actions/exec ./
          echo ----------------------------------------
          echo Invoking "npm --version" using @actions/exec fails:
          node -e "var exec = require('@actions/exec'); exec.exec('npm --version');"
bug

All 7 comments

@ericsciple, is there any scheduled release which includes the fix to this issue?

reopened since this isnt released yet

@1138-4EB i'll find out today

@eine sorry for the delay. Probably will be released sometime this weekend or on Monday.

Workaround is specify the full path. For example:

const npmPath = await io.which('npm', true);
await exec.exec(`"${npmPath}" --version`);

@eine the package was published a couple days ago.

@ericsciple, thanks! It works as expected! numworks/setup-msys2#24

Was this page helpful?
0 / 5 - 0 ratings