-
-
Notifications
You must be signed in to change notification settings - Fork 46
fix: patchShebangs in nonexecutable bin files (#106) #107
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
98c359b
a306d45
a75e8bc
48b2eaf
8c9b89b
40e09df
ff6d44a
60b003c
de6d2c6
99370e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||||||
{ nodejs, stdenv, mkShell, lib, fetchurl, writeText, writeTextFile, runCommand, fetchFromGitHub }: | ||||||||||
{ nodejs, stdenv, mkShell, lib, fetchurl, writeText, writeTextFile, runCommand, fetchFromGitHub, jq }: | ||||||||||
rec { | ||||||||||
default_nodejs = nodejs; | ||||||||||
|
||||||||||
|
@@ -331,6 +331,9 @@ rec { | |||||||||
|
||||||||||
${preInstallLinkCommands} | ||||||||||
|
||||||||||
cat package.json | jq -r '. | select(.bin != null) | .bin | values[]' | while read binTarget; do | ||||||||||
chmod +x "$binTarget" # patchShebangs will only patch executable files | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this should throw if binTarget is not found in my case: npmlock2nix.shell {
src = /tmp/package;
} the root package.json (/tmp/package/package.json) has a bin, or rather, npmlock2nix should ignore bin's for the root package (/tmp/package) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
even more, npmlock2nix.node_modules should ignore install scripts for the root package, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that so? I am not entirely sure that is true. Right now we do an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider this package.json {
"name": "root-package",
"version": "1",
"scripts": {
"postinstall": "node some/script.js"
},
"dependencies": {
"foo": "1.2.3"
}
} npmlock2nix has only two files for the root-package: package.json and package-lock.json these are symlinked to /build in npmlock2nix.node_modules Lines 365 to 368 in 33eb330
so the job of npmlock2nix.node_modules is only to populate node_modules |
||||||||||
done | ||||||||||
if grep -I -q -r '/bin/' .; then | ||||||||||
source $TMP/preinstall-env | ||||||||||
patchShebangs . | ||||||||||
|
@@ -348,6 +351,7 @@ rec { | |||||||||
|
||||||||||
nativeBuildInputs = nativeBuildInputs ++ [ | ||||||||||
nodejs | ||||||||||
jq | ||||||||||
]; | ||||||||||
|
||||||||||
propagatedBuildInputs = [ | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the
package.json
guranteed to be there?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also pass the
package.json
as 2nd argument to cat and avoid the cat invocation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is called for every npm package, these are required to have a package.json
its prettier this way ; ) but yes, lets save some nanoseconds and call only jq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json *should* always be there
and if its missing, we should throw a fatal error
currently, the script continues and throws later
i managed to hack together a broken node_modules with missing submodules ...
in that case i got
but package.json should be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also encountered a similar problem, where
jq
was complaining there was no "package.json" even though it was fine accesing it withcat
andls
when I was working on #108. I think usingcat <file> | jq ...
was mitigating the problem but then I stopped encountering it after fixing a some other part of the bash code. I still have no idea why that happened/happens.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. there are packages without a package.json,
for example type definitions (*.d.ts) or header files (*.h)
pnpm/pnpm#3728