yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.23k stars 1.07k forks source link

[Bug?]: Executable permission lost on bin file of local package after running yarn install #6281

Open quietnumeric opened 1 month ago

quietnumeric commented 1 month ago

Self-service

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
  2. Create package B with an executable bin:

  1. Create project A and install package B:
  1. Validate the successful execution of the bin file in project A:
package-b
# Output: 'before'
  1. Modify package B:
  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:

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