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 permission lost on bin file of local package after running yarn install #6281

Open
1 task
quietnumeric opened this issue May 8, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@quietnumeric
Copy link

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:

  1. Set up the project structure:
${workspace}
├── package-b
└── project-a
  1. Create package B with an executable bin:
  • package.json:

    {
      "name": "package-b",
      "bin": "./bin.js"
    }
  • bin.js:

    console.log('before');
  1. Create project A and install package B:
  • package.json:

    {
      "name": "project-a",
      "dependencies": {
        "package-b": "../package-b"
      }
    }
  • Run yarn add ../package-b to install package B.

  1. Validate the successful execution of the bin file in project A:
package-b
# Output: 'before'
  1. Modify package B:
  • Update bin.js:
// console.log('before');
console.log('after');
  1. 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.
  1. 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

@quietnumeric quietnumeric added the bug Something isn't working label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant