fix(npm): handle read-only bin files when setting up node_modules/.bin#32632
Merged
bartlomieju merged 6 commits intodenoland:mainfrom Mar 11, 2026
Merged
Conversation
Some npm tarballs ship bin files with read+execute but no write permission (e.g. `@formatjs/cli@2.15.0` uses mode 555). The `make_executable_if_exists()` function was opening these files with O_RDWR unconditionally, which fails with EACCES on such files. The fix opens the file read-only first to check if the execute bit is already set. Only if the execute bit is missing does it reopen with write access to chmod. This avoids the permission error for packages that already ship executable bin files without write permission. Closes denoland#29847 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Readonly bin file (mode 555): verifies no EACCES error - Non-executable file (mode 644): verifies execute bit is added - Nonexistent file: verifies returns false without error Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
kajukitli
approved these changes
Mar 11, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
lgtm, nice fix
opening read-only first to check permissions, then only reopening with write if chmod is needed, is the right approach.
the drop(file) before reopening is important — good that you included it.
solid test coverage for both the readonly case (mode 555) and the non-executable case (mode 644).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dsherret
approved these changes
Mar 11, 2026
Contributor
dsherret
left a comment
There was a problem hiding this comment.
LGTM, but CI is failing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@formatjs/cli@2.15.0uses mode555).make_executable_if_exists()was opening these files withO_RDWRunconditionally, causingEACCES("Permission denied").Closes #29847