-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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] Install fails if "bin" script doesn't exist #4597
Comments
#2632 possible regression |
The issue still exists today in npm 9. The issue occurs when two packages install the same executable name, but it doesn’t exist in the second package that is supposed to install that executable. It’s simplest to reproduce with npm workspaces, but it applies to other dependencies as well. Let’s say we have the following files:
{
"workspaces": [
"workspaces/*"
]
}
{
"name": "a",
"bin": {
"cli": "./cli.js"
}
}
{
"name": "b",
"bin": {
"cli": "./cli.js"
}
} Running If we create an empty file |
The problem is in https://github.com/npm/bin-links/blob/v4.0.1/lib/link-gently.js#L30-L33. This naively returns true if a link target was seen before. This indicates the file was linked succesfully. Then https://github.com/npm/bin-links/blob/main/lib/link-bin.js#L7 will try to make the non-existent file executable, which makes npm fail. |
`linkGently` would return true if a link target had been visited before. `linkBin` would then chmod the link `to`, regardless of whether this file exists. This causes `npm install` to fail if multiple packages link to a non-existent bin with the same name. By returning false in `linkGently`, `linkBin` no skips the chmod on the non-existent file. ## References Fixes npm/cli#4597
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
This is a duplicate of #2632. This has been closed, but I still encounter it using the latest version of npm.
When running
npm install
in a project that references abin
script that doesn’t exist, the command fails with the error:Expected Behavior
npm install
is succesfulSteps To Reproduce
git clone git@gitlab.com:appsemble/appsemble.git cd appsemble rm yarn.lock npm install
Environment
The text was updated successfully, but these errors were encountered: