fix: append (not prepend) action node dir to PATH for npm bootstrap
Test Action / Test with run_install (null, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (global, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (null, windows-latest) (push) Has been cancelled
Test Action / Test with default inputs (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with default inputs (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with default inputs (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with standalone (ubuntu-latest) (push) Has been cancelled
Test Action / Test with standalone (windows-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, macos-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, macos-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, ubuntu-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, ubuntu-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, windows-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, windows-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, macos-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, macos-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, ubuntu-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, ubuntu-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, windows-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, windows-latest) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (macos-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (ubuntu-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (windows-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with run_install (global, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (null, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (global, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (null, ubuntu-latest) (push) Has been cancelled
Test Action / Test with run_install (global, windows-latest) (push) Has been cancelled
Test Action / Test with run_install (null, windows-latest) (push) Has been cancelled
Test Action / Test with default inputs (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with default inputs (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with default inputs (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with dest (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with standalone (ubuntu-latest) (push) Has been cancelled
Test Action / Test with standalone (windows-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, macos-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, macos-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, ubuntu-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, ubuntu-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (10.33.0, windows-latest) (push) Has been cancelled
Test Action / Test version input is actually installed (9.15.5, windows-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, macos-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, macos-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, ubuntu-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, ubuntu-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (10.33.0, windows-latest) (push) Has been cancelled
Test Action / Test packageManager field is respected (9.15.5, windows-latest) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (macos-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (macos-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (ubuntu-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (ubuntu-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (windows-latest, 9.15.5) (push) Has been cancelled
Test Action / Test with devEngines.packageManager (windows-latest, >=9.15.0) (push) Has been cancelled
Test Action / Test with run_install (global, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (null, macos-latest) (push) Has been cancelled
Test Action / Test with run_install (global, ubuntu-latest) (push) Has been cancelled
#239 prepended `dirname(process.execPath)` to PATH so npm's `#!/usr/bin/env node` shebang resolves on GHE self-hosted runners where node isn't on PATH. But on runners with a prior `setup-node` step, this shadowed the user's installed toolchain with the runner-bundled node (e.g. externals/node24/bin), pairing the user's npm with a mismatched node — or picking up a broken `npm` shipped next to the runner-bundled node. Append instead so a user-installed toolchain on PATH keeps precedence; the runner's node dir remains as a fallback for the original #234 case where node isn't on PATH at all. Fixes #240
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -29,16 +29,20 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
|
|||||||
await writeFile(path.join(dest, 'package.json'), packageJson)
|
await writeFile(path.join(dest, 'package.json'), packageJson)
|
||||||
await writeFile(path.join(dest, 'package-lock.json'), JSON.stringify(lockfile))
|
await writeFile(path.join(dest, 'package-lock.json'), JSON.stringify(lockfile))
|
||||||
|
|
||||||
// Prepend the action's node directory to PATH so npm's
|
// Append the action's node directory to PATH so npm's
|
||||||
// `#!/usr/bin/env node` shebang resolves on runners (e.g. GHE
|
// `#!/usr/bin/env node` shebang resolves on runners (e.g. GHE
|
||||||
// self-hosted) where node isn't already on PATH. npm itself is
|
// self-hosted) where node isn't already on PATH. Append (not
|
||||||
// resolved via PATH — on the GitHub Actions runner it is not
|
// prepend) so a user-installed toolchain on PATH — e.g. from a
|
||||||
// co-located with `process.execPath`.
|
// prior `setup-node` step — keeps precedence; otherwise the
|
||||||
|
// runner-bundled node would shadow it and pair the user's npm
|
||||||
|
// with a mismatched node version. npm itself is resolved via
|
||||||
|
// PATH — on the GitHub Actions runner it is not co-located with
|
||||||
|
// `process.execPath`.
|
||||||
const nodeDir = path.dirname(process.execPath)
|
const nodeDir = path.dirname(process.execPath)
|
||||||
// On Windows, the PATH key casing varies; search case-insensitively.
|
// On Windows, the PATH key casing varies; search case-insensitively.
|
||||||
const pathKey = Object.keys(process.env).find(k => k.toUpperCase() === 'PATH') ?? 'PATH'
|
const pathKey = Object.keys(process.env).find(k => k.toUpperCase() === 'PATH') ?? 'PATH'
|
||||||
const currentPath = process.env[pathKey]
|
const currentPath = process.env[pathKey]
|
||||||
const npmEnv = { ...process.env, [pathKey]: currentPath ? nodeDir + path.delimiter + currentPath : nodeDir }
|
const npmEnv = { ...process.env, [pathKey]: currentPath ? currentPath + path.delimiter + nodeDir : nodeDir }
|
||||||
const npmExitCode = await runCommand('npm', ['ci'], { cwd: dest, env: npmEnv })
|
const npmExitCode = await runCommand('npm', ['ci'], { cwd: dest, env: npmEnv })
|
||||||
if (npmExitCode !== 0) {
|
if (npmExitCode !== 0) {
|
||||||
return npmExitCode
|
return npmExitCode
|
||||||
|
|||||||
Reference in New Issue
Block a user