Skip to content

fix: don't call chmod if the bin already has execution permission - #171

Merged
owlstronaut merged 1 commit into
npm:mainfrom
felipecrs:no-chmod
May 13, 2026
Merged

fix: don't call chmod if the bin already has execution permission#171
owlstronaut merged 1 commit into
npm:mainfrom
felipecrs:no-chmod

Conversation

@felipecrs

Copy link
Copy Markdown
Contributor

The fixBin function unconditionally called chmod on every bin file, even when the file already had the required permissions. This caused EPERM: operation not permitted, chmod errors in environments where the current user is not the file owner but the file already has the correct permissions.

This fixes it so that before calling chmod, the function stats the file and checks whether it already satisfies the requested mode. If it does, it skips the chmod call entirely.

References

Fixes #145
Refs pnpm/pnpm#3699 (comment)

@felipecrs
felipecrs requested a review from a team as a code owner May 11, 2026 19:51
@owlstronaut
owlstronaut merged commit 6049f08 into npm:main May 13, 2026
11 checks passed
@github-actions github-actions Bot mentioned this pull request May 13, 2026
@felipecrs
felipecrs deleted the no-chmod branch May 13, 2026 15:51
owlstronaut pushed a commit that referenced this pull request May 15, 2026
🤖 I have created a release *beep* *boop*
---


## [7.0.0](v6.0.0...v7.0.0)
(2026-05-15)
### ⚠️ BREAKING CHANGES
* `bin-links` now supports node `^22.22.2 || ^24.15.0 || >=26.0.0`
* template-oss-apply
* man pages listed in a package's `man` field are no longer linked into
the system man path on global install. `man <pkg>` will no longer work
for newly installed global packages. Use the package's own help
facilities (e.g. `npm help <cmd>`) instead.
### Features
*
[`0d66567`](0d66567)
[#172](#172) bump to new node
engine range (@owlstronaut)
*
[`c0aaffc`](c0aaffc)
[#172](#172) template-oss-apply
(@owlstronaut)
*
[`2612e67`](2612e67)
[#163](#163) stop installing man
pages for global installs (@owlstronaut)
### Bug Fixes
*
[`ab6bf0d`](ab6bf0d)
[#173](#173) use directory-boundary
checks for bin ownership validation (@owlstronaut)
*
[`6049f08`](6049f08)
[#171](#171) don't call `chmod` if
the bin already has execution permission (@felipecrs)
### Dependencies
*
[`af7684c`](af7684c)
[#172](#172)
`write-file-atomic@8.0.0`
*
[`a09e74a`](a09e74a)
[#172](#172) `read-cmd-shim@7.0.0`
*
[`93ec1ba`](93ec1ba)
[#172](#172) `proc-log@7.0.0`
*
[`5961e1f`](5961e1f)
[#172](#172)
`npm-normalize-package-bin@6.0.0`
*
[`47c5a72`](47c5a72)
[#172](#172) `cmd-shim@9.0.0`
### Chores
*
[`0919da0`](0919da0)
[#172](#172) template-oss-apply
(@owlstronaut)
*
[`897720a`](897720a)
[#172](#172) bumping
@npmcli/template-oss from 4.30.0 to 5.1.0 (@owlstronaut)
*
[`0ff0be3`](0ff0be3)
[#175](#175) template-oss-apply
(@owlstronaut)
*
[`f02cef9`](f02cef9)
[#163](#163) template-oss-apply
(@owlstronaut)
*
[`88eda3f`](88eda3f)
bump @npmcli/eslint-config from 5.1.0 to 6.0.0 (#157) (@dependabot[bot])
*
[`0f07dcd`](0f07dcd)
[#161](#161) bump
@npmcli/template-oss from 4.28.1 to 4.29.0 (#161) (@dependabot[bot],
@npm-cli-bot)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] noop when there is nothing to change

2 participants