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] executable permissions aren't set if a .bin symlink already exists #4149

Open
2 tasks done
bglw opened this issue Dec 9, 2021 · 0 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@bglw
Copy link

bglw commented Dec 9, 2021

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If a folder within node_modules is deleted and npm install is run, npm will not mark any bin files as executable if the symlink to that file still exists in node_modules/.bin

This means that if node_modules was only partially cleaned up, the re-install can land in a broken state. We're seeing this happen on CI environments with quirks in the caching / preserving of node_module folders.

Expected Behavior

A re-install should also re-update all bin files to have executable permissions.

Steps To Reproduce

  1. Using Node v16.13.1 (npm v8.1.2) on macOS or Ubuntu
  2. With the package.json
{
  "name": "symlink-test",
  "private": true,
  "scripts": {
    "start": "webpack"
  },
  "dependencies": {
    "webpack": "^5.65.0"
  }
}
  1. Run npm install
  2. Run npm start and you will see CLI for webpack must be installed. (indicating that the webpack command successfully executed)
  3. Run ls -l node_modules/webpack/bin/webpack.js and see the permissions -rwxr-xr-x
  4. Run rm -rf ./node_modules/webpack/
  5. Run npm install
  6. Run npm start and you will see sh: path/to/node_modules/.bin/webpack: Permission denied
  7. Run ls -l node_modules/webpack/bin/webpack.js and see the permissions -rw-r--r--

Previous NPM versions

Following the above steps in npm 6 or npm 7 will not throw the error, and using ls -l node_modules/webpack/bin/webpack.js will always show the permissions -rwxr-xr-x, even on this partial install state.

Environment

  • npm: v8.1.2
  • Node: v16.13.1
  • OS: macOS 11.6
  • platform: Macbook Pro
  • npm config:
; "user" config from /Users/liambigelow/.npmrc

//npm.pkg.github.com/:_authToken = (protected) 
//registry.npmjs.org/:_authToken = (protected) 

; node bin location = /Users/liambigelow/.nvm/versions/node/v16.13.1/bin/node
; cwd = /Users/liambigelow/tmp/symtest3
; HOME = /Users/liambigelow
; Run `npm config ls -l` to show all defaults.

NOTE: This behavior was initially observed on Ubuntu images running inside Docker. I am reproducing it on a Macbook Pro.

@bglw bglw added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

1 participant