Skip to content

fix: use prepare instead of postinstall for buf generate - #142

Merged
ChrisMBarr merged 1 commit into
ChrisMBarr:mainfrom
bhdoggett:fix-consumer-postinstall
Aug 11, 2026
Merged

ChrisMBarr merged 1 commit into
ChrisMBarr:mainfrom
bhdoggett:fix-consumer-postinstall

Conversation

@bhdoggett

@bhdoggett bhdoggett commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes Issue #141.

postinstall runs for anyone installing the published package, but buf.gen.yaml, the .proto sources, and @bufbuild/buf (a devDependency) are all absent from the tarball — so npx buf generate fails with could not determine executable to run and aborts the install. Consumers have to use --ignore-scripts, which is awkward in CI/Docker and disables postinstall for every other dependency too.

prepare runs in exactly the cases that need codegen — local npm install/npm ci (so CI is unchanged), git-URL installs, and before npm publish — and not for tarball consumers. Dropping npx also uses the local node_modules/.bin/buf directly instead of resolving from the registry.

Verified: npm ci still generates src/v7/gen; lint, all 82 tests, and both builds pass. yarn add propresenter-parser@1.1.0 reproduces the failure; yarn add of a tarball packed from this branch installs cleanly and loads all 6 exports.

Context: using this in a real project for PP7 parsing — thanks for the recent v7 support.

Installing the published package fails for consumers: `postinstall` runs
`npx buf generate`, but neither `buf.gen.yaml` nor the `.proto` sources are
in the published tarball, and `@bufbuild/buf` is a devDependency that isn't
installed for consumers. npx then fails with "could not determine executable
to run", aborting the install.

`prepare` still runs for local development (`npm install` / `npm ci`, so CI
is unaffected), for git-URL installs, and before `npm publish` — but not when
the package is installed as a dependency from a tarball. Dropping `npx` also
means the local `buf` binary from node_modules/.bin is used directly rather
than resolved from the registry.

Consumers can now install without needing `--ignore-scripts`.
@ChrisMBarr

Copy link
Copy Markdown
Owner

Good catch, thank you!

@ChrisMBarr
ChrisMBarr merged commit 3124949 into ChrisMBarr:main Aug 11, 2026
1 check passed
@bhdoggett

bhdoggett commented Aug 11, 2026 via email

Copy link
Copy Markdown
Contributor Author

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.

2 participants