Skip to content
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

bug: patchShebangs fails when files are not executable #106

Open
milahu opened this issue Sep 14, 2021 · 0 comments · May be fixed by #107
Open

bug: patchShebangs fails when files are not executable #106

milahu opened this issue Sep 14, 2021 · 0 comments · May be fixed by #107

Comments

@milahu
Copy link
Contributor

milahu commented Sep 14, 2021

package.json

{
  "name": "npmlock2nix-bug-patchshebangs",
  "version": "1.0.0",
  "scripts": {
    "install": "cross-env echo hello"
  },
  "dependencies": {
    "cross-env": "*"
  }
}

error

sh: /build/node_modules/.bin/cross-env: /usr/bin/env: bad interpreter: No such file or directory

/build/node_modules/.bin/cross-env is a symlink to
/build/node_modules/cross-env/src/bin/cross-env.js

the source file cross-env/src/bin/cross-env.js
is NOT patched by patchShebangs (find "$@" -type f -perm -0100)
because it is not executable (file mode 0644)

solutions

in the preinstall hook, add

# patchShebangs will patch only executable files
cat package.json | jq -r '. | select(.bin != null) | .bin | values[]' \
  | while read binTarget; do chmod +x "$binTarget"; done

maybe avoid jq and use nix to extract a list of binTargets
no, this concerns dependencies, where we dont have the json files parsed into nix

milahu added a commit to milahu/npmlock2nix that referenced this issue Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant