-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch the shebang of files specifed with bin field #108
Patch the shebang of files specifed with bin field #108
Conversation
Sometimes files specified with the bin field of package.json are missing their executable bits when they are extracted. npm must be setting their executable bits at some stage of `npm install` life cycle because by the time the command is complete, they are executable. But at "preinstall" stage, which is when we patch the shebangs, those files are not executable thus skipped by the `patchShebangs` function. We are now using `jq` to get the files specified with the "bin" field of "package.json and patches the ones missing their executable bit.
While trying to package https://github.com/eez-open/studio, using this commit patches 7 extra files, where at least one of those are used during the install. Without this commit, unpatched shebangs produces an error similar to |
Also somewhat related, currently this project uses hook scripts (specifically "preinstall" hook) to patch the shebangs. But as far as I can tell, hook scripts are removed from npm v7[1][2]. Do you have any plans to change the way shebangs are patched in a way that could also work with npm v7? [1] npm/cli#2692 |
Wow, I didn't see #107 |
good to know! we can run the lifecycle scripts manually Lines 288 to 302 in de6d2c6
while were at it, we could fully replace (and of course, merge all the npm2nix/yarn2nix projects into one) |
much easier in javascript https://github.com/milahu/npm-install-mini i use the same folder structure like pnpm (deep node_modules with symlinks),
works at least with cowsay ^^
|
@milahu |
Sometimes files specified with the bin field of package.json are missing
their executable bits when they are extracted[1]. npm must be setting their
executable bits at some stage of
npm install
life cycle because by thetime the command is complete, they are executable. But at "preinstall"
stage, which is when we patch the shebangs, those files are not
executable thus skipped by the
patchShebangs
function.To fix this,
jq
is used to get the files specified with the "bin" field of"package.json and the ones missing their executable bit are
chmod
'ed and patched.[1]: E.g.,
package/bin.js
extracted from https://registry.npmjs.org/prebuild-install/-/prebuild-install-6.0.1.tgz has its executable bit correctly set while the one from doesn't https://registry.npmjs.org/prebuild-install/-/prebuild-install-6.1.4.tgz