[Bug?]: Executable permission lost on bin file of local package after running yarn install
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
When a local package (Package B) with an executable bin file is installed in another project (Project A), and then Package B is updated, running yarn install in Project A to update the package results in the loss of the executable permission on the bin file.
The executable permission can be restored manually on the bin file, and the package will work as expected.
If the executable permission is set on the bin file in the local Package B, the issue does not occur.
However, it is unnatural for the executable permission to be lost when updating the package. This behavior does not occur when installing remote packages, and local packages should behave in the same way as remote packages.
To reproduce
To reproduce the issue, follow these steps:
- Set up the project structure:
${workspace}
├── package-b
└── project-a
- Create package B with an executable bin:
-
package.json:{ "name": "package-b", "bin": "./bin.js" } -
bin.js:console.log('before');
- Create project A and install package B:
-
package.json:{ "name": "project-a", "dependencies": { "package-b": "../package-b" } } -
Run
yarn add ../package-bto install package B.
- Validate the successful execution of the bin file in project A:
package-b
# Output: 'before'
- Modify package B:
- Update bin.js:
// console.log('before');
console.log('after');
- Update package B in project A and execute the bin file:
yarn install
package-b
You will encounter the following error message:
Volta error: Could not execute `package-b`
Please ensure you have correct permissions to access the file.
- To temporarily resolve the issue, you can either:
- Remove and reinstall package B:
yarn remove package-b
yarn add ../package-b
- Set the executable permission on bin.js in package B:
chmod +x bin.js
These reproduction steps clearly outline the process of setting up the project structure, creating the necessary files, and demonstrating the loss of executable permission on the bin file after running yarn install. The temporary workarounds are also provided.
Environment
System:
OS: macOS 13.5
CPU: (10) arm64 Apple M2 Pro
Binaries:
Node: 20.9.0 - /private/var/folders/gh/9qf38ks575gdynfchc6z_2j00000gn/T/xfs-5139bdfb/node
Yarn: 4.0.1 - /private/var/folders/gh/9qf38ks575gdynfchc6z_2j00000gn/T/xfs-5139bdfb/yarn
npm: 10.1.0 - ~/.volta/tools/image/node/20.9.0/bin/npm
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the package.json and bin.js setup using yarn add ../package-b, then update bin.js and run yarn install. Trace Yarn's local-package update and bin handling to determine where executable permission is lost; done means package-b still executes after the update without manual chmod.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100