You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Executable broken when called with PKG_EXECPATH set to its own absolute path #1565
Setting the PKG_EXECPATH environment variable to the absolute path of the executable produces an error:
$ tee test.js <<<"console.log('test');"console.log('test');
$ pkg test.js --target=node16-linux-x64 --output=testpkg@5.5.2
$ ./testtest
$ PKG_EXECPATH=$(realpath test) ./testpkg/prelude/bootstrap.js:1813 if (error.code !== 'MODULE_NOT_FOUND') throw error; ^TypeError: String.prototype.startsWith called on null or undefined at startsWith (<anonymous>) at Function.Module._resolveFilename (node:internal/modules/cjs/loader:849:7) at Function._resolveFilename (pkg/prelude/bootstrap.js:1811:44) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.runMain (pkg/prelude/bootstrap.js:1847:12) at node:internal/main/run_main_module:17:47
$ PKG_EXECPATH=$(realpath test) ./test argumentnode:internal/modules/cjs/loader:936 throw err; ^Error: Cannot find module '/path/to/current/directory/argument' at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function._resolveFilename (pkg/prelude/bootstrap.js:1819:46) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Function.runMain (pkg/prelude/bootstrap.js:1847:12) at node:internal/main/run_main_module:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
Activity
0x2b3bfa0 commentedon Mar 24, 2022
Related Issues
0x2b3bfa0 commentedon Mar 24, 2022
Explanation
pkg/prelude/bootstrap.js
Lines 77 to 89 in 2ef4cd9
TypeError: String.prototype.startsWith called on null or undefinedtrue(executable called withPKG_EXECPATHset to its own absolute path)false(executable called without arguments, or the first argument is a hyphen)process.argv[1]remainsundefinedbecause no other assignment is being madeENTRYPOINTbecomesprocess.argv[1]at line 88Error: Cannot find module '/path/to/current/directory/argument'true(executable called withPKG_EXECPATHset to its own absolute path)true(executable called with one or more arguments, and the first argument isn't a hyphen)process.argv[1]becomespath.resolve(process.argv[1])1ENTRYPOINTbecomesprocess.argv[1]at line 88pkg/prelude/bootstrap.js
Line 1846 in 2ef4cd9
Value of
ENTRYPOINT(eitherundefinedor a non–existent path) is used to call the_loadfunction, producing an error.Footnotes
Namely,
'/path/to/current/directory/argument'↩0x2b3bfa0 commentedon Mar 24, 2022
It turns out that there aren't other solutions apart from unsetting
PKG_EXECPATHas proposed on #897. At least, I haven't found any.