Skip to content

Build a package that ships a binding.gyp and names no install script - #1206

Draft
tolgaergin wants to merge 6 commits into
fix/sandbox-run-accessfrom
feat/implied-native-build
Draft

tolgaergin wants to merge 6 commits into
fix/sandbox-run-accessfrom
feat/implied-native-build

Conversation

@tolgaergin

@tolgaergin tolgaergin commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A package with a binding.gyp at its root and no install or preinstall script is built with node-gyp rebuild by npm, pnpm, yarn and bun, and the registry reports it as having an install script. LPM read only the scripts a manifest names, so such a package (segfault-handler, iconv, node-expat and others) was installed unbuilt: nothing to approve, nothing to say a build was missing, and a failure only when the project loaded it.

Change

The implied build is the package's install script wherever its install-time scripts are read. It is hashed, classified (node-gyp rebuild is a green command) and listed by lpm approve-scripts like a named script, and lpm rebuild runs it. The rule is npm's: a binding.gyp file at the package root, no install and no preinstall script, and no "gypfile": false in the manifest.

A package that names only a postinstall script and ships a binding.gyp gets the build too. Its script hash changes, so an approval given before this change is asked for again.

An install records the revision of the rules that say which scripts a package has. A project installed under an earlier revision is installed again once, so such packages are listed without waiting for an unrelated change.

lpm query ":scripts", lpm audit, the install summary and the warning lpm add prints count the implied build as well.

The scan of what a binding.gyp runs is stricter, because more packages now reach it. gyp evaluates the file as Python before it expands anything, so the scan reads it as the plain literal such files are written as, with strings decoded as Python decodes them. A <!(…), >!(…) or ^!(…) command is reported as before when it is a plain shell command. The scan is left incomplete, which sends the package to review, for anything else that can run something:

  • a file that isn't a plain literal, or one the scan can't read;
  • a named or list-form expansion, a command built from a variable, and an expansion that never closes;
  • a condition that does more than compare names, strings and numbers (gyp evaluates conditions as Python);
  • actions, rules, included files and any other key the scan doesn't know to be inert;
  • a setting that names a program or a command line, and a dependency on another build file.

The config.gypi and common.gypi that node-gyp adds from the package's directory are read the same way. Of 66 command-free binding.gyp files from packages on the test machine, three are now sent to review: one for actions, one for a second build file, one for a key since added to the inert list.

Not changed: only a command the static gate marks Red is reported. One it marks Amber, such as node -p "require('node-addon-api').include", is not.

Tests

  • install_native_build (workflow): a package with a binding.gyp and no scripts waits for review with an install phase on the green tier, which fails before the change; one with "gypfile": false has nothing to review.
  • Unit tests for the rule, for the script hash (the implied build hashes like the same script named), for the readers in the CLI and of registry metadata, for the gyp reader (each way of spelling a command, each thing that leaves the scan incomplete, and a plain file that needs no review), and for the install-state revision.

🤖 Generated with Claude Code

tolgaergin and others added 6 commits November 16, 2026 18:06
A package with a `binding.gyp` at its root and no `install` or
`preinstall` script is built with `node-gyp rebuild` by npm, pnpm, yarn
and bun, and the registry reports it as having an install script. LPM read
only the scripts the manifest names, so such a package was installed
unbuilt, with nothing to approve and nothing to say it needed a build.

The implied build is now the package's `install` script wherever its
scripts are read: it is hashed, classified and listed for approval like a
named one, and `lpm rebuild` runs it. A manifest with `"gypfile": false`
opts out, as it does for npm.

A package that names only a `postinstall` script and ships a
`binding.gyp` gets the build too, so its script hash changes and an
earlier approval of it is asked for again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`lpm query ":scripts"` and its `--assert-none` read a manifest's named
scripts only, so a package built from its `binding.gyp` wasn't matched.
`lpm audit` reported lifecycle scripts only from the list the registry
gives, which has no entry for the implied build; it now also honors the
registry's own flag for a version that has an install script.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… again

- The scan of a `binding.gyp` read `<!(…)` and `<!@(…)` up to the first
  closing bracket. It now reads the `>` and `^` forms too, to the bracket
  that closes them, and leaves the scan incomplete for what it can't
  judge: a `pymod_do_main` expansion, which imports a Python module of the
  package, an included `.gypi`, an expansion that never closes, and a
  `binding.gyp` it can't read. More packages reach this scan now that one
  with only a `binding.gyp` has a build.
- An install records the revision of the rules that say which scripts a
  package has. A project installed under another revision is installed
  again once, so a package that had nothing to approve is listed, and an
  approval that no longer covers what would run is asked for again.
- The quality check for install scripts honors `"gypfile": false`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A command in a `binding.gyp` sits inside a quoted string, so its own
quotes are escaped there. It was reported, and classified, with the
escapes left in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…leaves unread

The scan looked for `<!(…)` in the text of a binding.gyp. gyp evaluates
the file as Python first, so a command could be spelled so the scan
didn't see it: with an escape, as two strings side by side, behind a
variable, as a list, or under a name. A condition is itself Python that
gyp evaluates, and actions, rules and build events hold commands that
run during the build.

The file is now read as the plain literal such files are written as,
strings decoded as Python decodes them. A command is reported as before
when it is a plain shell command. Everything else that can run
something leaves the scan incomplete, so the package is reviewed on its
own: a file that isn't a plain literal, a named or list expansion, a
command built from a variable, a condition that does more than compare,
a key the reader doesn't know to be inert, a setting that names a
program or a command line, and a dependency on another build file. The
config.gypi and common.gypi that node-gyp adds from the package's
directory are read the same way.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ummarized

The audit already counted a version the registry flags as having an
install script without listing one. The install summary, the warning
`lpm add` prints and the check for anything worth warning about read
only the list, and so missed a package whose build its binding.gyp
implies. They now share one reader, which names the install phases the
manifest declares and `install` when it declares none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@tolgaergin
tolgaergin force-pushed the feat/implied-native-build branch from 6925b14 to c15cb62 Compare November 16, 2026 18:13

This branch has not been deployed

No deployments
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.

1 participant