Skip to content

fix: pack node-gyp's gyp entrypoints as executable - #12652

Merged
zkochan merged 2 commits into
pnpm:mainfrom
kyungseopk1m:fix/node-gyp-gyp-executable-files
Jun 26, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
kyungseopk1m:fix/node-gyp-gyp-executable-files

Conversation

@kyungseopk1m

@kyungseopk1m kyungseopk1m commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The bundled node-gyp ships two gyp entrypoints — gyp/gyp_main.py and gyp/gyp — as non-executable (0644) inside the pnpm and @pnpm/exe tarballs. Both start with a shebang and are exec'd directly by gyp's make generator when it regenerates the Makefile during a from-source native addon build, so the build fails with Permission denied / make: *** [Makefile] Error 126.

#11485 restored the execute bit on the node-gyp bin shims for the same class of bug (#11483) but missed these two gyp entrypoints. This adds them to PUBLISH_EXECUTABLE_FILES in the meta-updater, which writes publishConfig.executableFiles for both the pnpm and @pnpm/exe manifests.

Reproduced on the published 11.9.0 tarballs:

$ npm pack [email protected]
$ tar -tvf pnpm-11.9.0.tgz | grep 'node-gyp/\(gyp\|bin\)'
-rw-r--r--  node-gyp/gyp/gyp_main.py    # 0644, missing from the allowlist
-rw-r--r--  node-gyp/gyp/gyp            # 0644, missing from the allowlist
-rwxr-xr-x  node-gyp/bin/node-gyp.js    # 0755, already on the allowlist

@pnpm/[email protected] packs them the same way. Files on publishConfig.executableFiles come out 0755 while the two gyp entrypoints, which carry the same shebangs, come out 0644.

Closes #12455

Squash Commit Body

gyp's make generator execs gyp/gyp_main.py and gyp/gyp directly through
their shebangs when it regenerates the Makefile during a from-source
native build. They were missing from publishConfig.executableFiles, so
they got packed at 0644 and the build failed with "Permission denied"
(make error 126).

pnpm/pnpm#11485 fixed the node-gyp bin shims but not these two. Add them
to PUBLISH_EXECUTABLE_FILES so the pnpm and `@pnpm/exe` tarballs pack
them at 0755.

Closes pnpm/pnpm#12455

Checklist

  • No pacquet/ port needed — this only changes how the pnpm/@pnpm/exe tarballs are packed (publishConfig.executableFiles), which has no equivalent in the Rust port.
  • Added a changeset.
  • No unit test added — the allowlist is regenerated and checked by meta-updater --test (lint:meta) in CI, same as fix(exe): restore execute bit on node-gyp shims in @pnpm/exe #11485.
  • Docs not affected.

Summary by CodeRabbit

  • Bug Fixes
    • Updated packaged releases to include node-gyp entrypoint files with the correct executable permissions.
    • Fixed build failures for native addons that previously hit “Permission denied” and related execution errors.
    • Improved the reliability of building from source by ensuring all required node-gyp artifacts are bundled correctly in the produced tarballs.

gyp's make generator execs gyp/gyp_main.py and gyp/gyp directly through
their shebangs when it regenerates the Makefile during a from-source
native build. They were missing from publishConfig.executableFiles, so
they got packed at 0644 and the build failed with "Permission denied"
(make error 126).

pnpm#11485 fixed the node-gyp bin shims but not these two. Add them
to PUBLISH_EXECUTABLE_FILES so the pnpm and `@pnpm/exe` tarballs pack
them at 0755.

Closes pnpm#12455
@kyungseopk1m
kyungseopk1m requested a review from zkochan as a code owner June 25, 2026 08:55
Copilot AI review requested due to automatic review settings June 25, 2026 08:55
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2c69e838-83e5-4625-a8a5-af2aaf5d2a93

📥 Commits

Reviewing files that changed from the base of the PR and between b91d777 and fc86c47.

📒 Files selected for processing (1)
  • .changeset/node-gyp-gyp-executable.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/node-gyp-gyp-executable.md

📝 Walkthrough

Walkthrough

The PR adds gyp_main.py and gyp/gyp to the executable-file allowlists used when packaging pnpm and @pnpm/exe, and records the change in a changeset.

Changes

Restore node-gyp gyp executables

Layer / File(s) Summary
Executable allowlist updates
\.meta-updater/src/index.ts, pnpm11/pnpm/package.json, pnpm11/pnpm/artifacts/exe/package.json, .changeset/node-gyp-gyp-executable.md
The meta-updater executable-file list and both package manifests now include gyp_main.py and gyp/gyp, and the changeset notes the packaged executable-bit restoration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Restore executable permissions for node-gyp gyp entrypoints [#12455] ✅

Possibly related PRs

  • pnpm/pnpm#11485 — Updates the same packaging metadata path for node-gyp executable permissions, and this PR extends it to the missing gyp entrypoints.

Suggested labels

product: pnpm@11

Suggested reviewers

  • zkochan
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix packaging: ship node-gyp gyp entrypoints as executable files
🐞 Bug fix ⚙️ Configuration changes 🕐 10-20 Minutes

Grey Divider

Description

• Add node-gyp gyp entrypoints to the executable-files allowlist during packaging.
• Regenerate publishConfig.executableFiles for pnpm and @pnpm/exe tarballs.
• Add a changeset documenting the native build failure and the permission fix.
Diagram

graph TD
  MU(["meta-updater"]) --> AL["PUBLISH_EXECUTABLE_FILES"] --> EXE["@pnpm/exe package.json"] --> PK["npm pack/publish"] --> T1[("@pnpm/exe tgz")]
  AL --> PNPM["pnpm package.json"] --> PK --> T2[("pnpm tgz")]

  subgraph Legend
    direction LR
    _proc(["Process/Tool"]) ~~~ _file["Manifest/File"] ~~~ _art[("Packaged artifact")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Post-pack chmod step
  • ➕ Can fix permissions without touching executableFiles lists
  • ➕ Potentially simpler if many files need mode fixes later
  • ➖ More brittle across platforms and pack tooling
  • ➖ Harder to reason about than declarative publishConfig.executableFiles
  • ➖ Easy to miss in some publish paths
2. Add CI smoke test that inspects tarball modes
  • ➕ Prevents regressions by validating actual packed permissions
  • ➕ Catches other missing executable entries beyond node-gyp
  • ➖ Adds CI time and some platform-specific tar mode parsing complexity
  • ➖ Still requires maintaining the allowlist as the source of truth
3. Upstream fix in the vendored node-gyp packaging process
  • ➕ Addresses the root cause closer to where the files originate
  • ➖ Doesn’t help already-published pnpm/@pnpm/exe artifacts
  • ➖ May not apply if pnpm’s packaging step is what drops the exec bit

Recommendation: Keep the current approach: extending PUBLISH_EXECUTABLE_FILES is the most direct and declarative fix for npm’s tarball mode behavior and matches prior fixes (e.g., for node-gyp bin shims). If regressions have been common, consider adding an optional CI check that npm packs and asserts executable modes for the allowlist to validate the end artifact.

Files changed (4) +14 / -2

Bug fix (1) +2 / -0
index.tsExtend executable allowlist with node-gyp gyp entrypoints +2/-0

Extend executable allowlist with node-gyp gyp entrypoints

• Adds 'dist/node_modules/node-gyp/gyp/gyp_main.py' and 'dist/node_modules/node-gyp/gyp/gyp' to 'PUBLISH_EXECUTABLE_FILES'. This ensures the meta-updater propagates these paths into package manifests so they’re packed as 0755.

.meta-updater/src/index.ts

Documentation (1) +6 / -0
node-gyp-gyp-executable.mdAdd changeset for node-gyp gyp entrypoint exec-bit fix +6/-0

Add changeset for node-gyp gyp entrypoint exec-bit fix

• Introduces a patch changeset for 'pnpm' and '@pnpm/exe'. Documents why 'gyp_main.py' and 'gyp' must be executable to avoid native build failures in gyp’s make generator.

.changeset/node-gyp-gyp-executable.md

Other (2) +6 / -2
package.jsonMark gyp entrypoints executable in @pnpm/exe publishConfig +3/-1

Mark gyp entrypoints executable in @pnpm/exe publishConfig

• Updates 'publishConfig.executableFiles' to include the two node-gyp gyp entrypoints alongside the existing node-gyp shims. This makes the packaged tarball preserve execute permissions for these shebang scripts.

pnpm11/pnpm/artifacts/exe/package.json

package.jsonMark gyp entrypoints executable in pnpm publishConfig +3/-1

Mark gyp entrypoints executable in pnpm publishConfig

• Updates 'publishConfig.executableFiles' to include the two node-gyp gyp entrypoints alongside the existing node-gyp shims. This prevents 'Permission denied' failures during from-source native addon builds that regenerate Makefiles.

pnpm11/pnpm/package.json

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (1) 📜 Skill insights (0)

Context used

Grey Divider


Remediation recommended

1. Node-gyp exec bits untested 📎 Requirement gap ☼ Reliability
Description
The PR updates publishConfig.executableFiles to ship additional node-gyp gyp entrypoints as
executable, but does not add an automated regression check that asserts the executable bits for the
known node-gyp tooling paths in the packed artifact. This can allow future packaging changes to
reintroduce non-executable entrypoints without CI failing.
Code

.meta-updater/src/index.ts[R32-33]

+  './dist/node_modules/node-gyp/gyp/gyp_main.py',
+  './dist/node_modules/node-gyp/gyp/gyp',
Evidence
PR Compliance ID 3 requires a build/CI validation that asserts executable bits for the known
node-gyp tooling entrypoints in the packed artifact. The PR changes the executable allowlist by
adding gyp_main.py and gyp, but the existing packaging tests only assert executable mode
behavior for a generic fixture and do not check the specific node-gyp paths, so this requirement is
still not met.

Add packaging regression checks for executable bits on bundled node-gyp tooling
.meta-updater/src/index.ts[24-34]
pnpm11/releasing/commands/test/publish/pack.ts[370-397]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Compliance requires an automated packaging regression check that fails CI if the known bundled node-gyp entrypoints are not executable in the to-be-packed artifact. The current PR updates the allowlist (`publishConfig.executableFiles`), but there is no targeted test asserting executable bits for the specific node-gyp shim + gyp entrypoint paths.

## Issue Context
`pnpm pack` sets tar entry modes to `0o755` only for paths detected as executables. Regressions can happen if the allowlist changes, generation code changes, or packaging behavior changes.

## Fix Focus Areas
- pnpm11/releasing/commands/test/publish/pack.ts[370-397]
- .meta-updater/src/index.ts[24-34]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit fc86c47

Results up to commit fc86c47


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled
Results up to commit b91d777


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled
Results up to commit b91d777


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Auto-approved notes - no code review findings
- 'auto_approve_for_no_suggestions' flag enabled
Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b91d777

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/node-gyp-gyp-executable.md:
- Line 6: The changeset description is too implementation-heavy and includes
internal rationale/history; rewrite the entry to be user-facing only. Update the
changeset content using the changeset file’s descriptive summary so it simply
states that pnpm now preserves execute permissions for the bundled node-gyp gyp
entrypoints, without mentioning packaging internals, build failure details, or
linked issue history.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f9c30db6-60fe-451e-921d-a1edec84cf49

📥 Commits

Reviewing files that changed from the base of the PR and between 6e45ce1 and b91d777.

📒 Files selected for processing (4)
  • .changeset/node-gyp-gyp-executable.md
  • .meta-updater/src/index.ts
  • pnpm11/pnpm/artifacts/exe/package.json
  • pnpm11/pnpm/package.json

Comment thread .changeset/node-gyp-gyp-executable.md Resolved
Move the implementation detail to the commit history and keep the
changeset to a short release note, as CONTRIBUTING asks.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit fc86c47

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit fc86c47

@github-actions github-actions Bot added reviewed: coderabbit CodeRabbit submitted an approving review state: automerge labels Jun 26, 2026
@zkochan
zkochan merged commit 96da7c5 into pnpm:main Jun 26, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

node-gyp gyp entrypoints (gyp/gyp_main.py, gyp/gyp) still ship as non-executable

3 participants