Skip to content

chore: fix deploy artifact path in example build scripts - #794

Open
MarkFeder wants to merge 3 commits into
solana-foundation:mainfrom
MarkFeder:chore-fix-pinocchio-native-deploy-paths
Open

MarkFeder wants to merge 3 commits into
solana-foundation:mainfrom
MarkFeder:chore-fix-pinocchio-native-deploy-paths

Conversation

@MarkFeder

@MarkFeder MarkFeder commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Linked issue

Fixes #787

Replaces #702, which the PR-hygiene bot closed before the issue was accepted; GitHub doesn't let the author reopen it.

What and why

The deploy npm scripts and cicd.sh in the native and Pinocchio examples ran:

solana program deploy ./program/target/so/program.so

cargo build-sbf --sbf-out-dir=./program/target/so names the artifact after the crate, not program (e.g. transfer_tokens_program.so), so the documented deploy step failed with "No such file".

Every deploy command now names the file the build actually writes, <crate lib name>.so, taken from cargo metadata and cross-checked against the fixture each example's tests load:

solana program deploy ./program/target/so/token_2022_transfer_fee_pinocchio_program.so

A *.so glob would be shorter, but pnpm runs package.json scripts through cmd.exe on Windows, which passes the glob through literally, so the explicit name is the only form that works on every OS.

Also fixed while checking every deploy path against its crate:

  • Seven native cicd.sh built without --sbf-out-dir and deployed ./program/target/deploy/program.so, which a workspace member never produces. They now build into ./program/target/so like the rest.
  • Four token-2022 native package.json deployed hello_solana_program.so (copy-paste).
  • Seven Pinocchio cicd.sh used the deprecated --bpf-out-dir; Anza v4's cargo build-sbf only documents --sbf-out-dir.
  • basics/cross-program-invocation/native deployed hand.so/lever.so (cicd.sh) and program.so (package.json). Both now deploy the two crate-named artifacts; the npm script chains them with &&, which works in cmd.exe too.
  • cicd.sh gets set -e (and pipefail where it pipes into grep), so a failed build stops before deploying.
  • basics/counter/native/README.md said pnpm deploy, which is pnpm's own workspace command, not the script; it now says pnpm run deploy.

basics/transfer-sol/asm builds with sbpf and is left alone.

Testing

  • A script compared every solana program deploy path in native/Pinocchio package.json and cicd.sh (96 commands) with <--sbf-out-dir>/<crate lib name>.so from cargo metadata: 0 mismatches.
  • In a Linux container, for all 48 native/Pinocchio examples with a cicd.sh: ran bash cicd.sh (real cargo build-sbf), then pnpm run deploy, with a stand-in solana that only accepts program deploy <path> when the path is an SBF ELF the build produced. The same harness on current main fails on the broken examples, so it does catch them.
  • On Windows, a package.json script under pnpm 10.33.0 receives ./program/target/so/*.so literally (file not found), while the explicit path and the && chain resolve.
  • prettier --check . passes. CI doesn't run deploy, so it is otherwise unaffected.

AI disclosure

Check exactly one. See CONTRIBUTING.md.

  • No AI tooling was used beyond editor autocomplete.
  • AI tooling was used. Tool and extent: Claude Code helped make the edits, build the verification scripts and write this description; I reviewed the changes.

The `build`/`deploy` npm scripts and cicd.sh deploy `program.so`, but
`cargo build-sbf --sbf-out-dir=./program/target/so` emits an artifact named
after the crate (e.g. `token_2022_transfer_fee_pinocchio_program.so`), so the
documented `solana program deploy` step fails to find the file.

Use a `*.so` glob so the deploy step resolves the built artifact regardless of
its crate-derived name, across the single-program native and pinocchio
examples. CI is unaffected (it builds to ./tests/fixtures and never runs
deploy).

Excluded:
- The asm example (basics/transfer-sol/asm): it uses the sbpf toolchain with a
  different output layout and artifact name; it needs a separate fix.
- Multi-program examples (basics/cross-program-invocation): their build emits
  more than one .so, so a single glob would pass multiple paths to
  `solana program deploy`, which takes one. Left unchanged.
@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

The PR points deployment commands at the actual crate-named build files.

  • Example deploy commands now point to their crate-named program files.
  • The cross-program example builds and deploys its hand and lever programs separately.

The earlier, unnumbered finding about deploying old builds is fixed: the affected scripts now stop before deployment when a build fails. No new actionable issues were found.

Reviews (3) · Last reviewed commit: "chore: deploy the real artifact name so ..." · Reviewed by Greptile

Comment thread basics/account-data/native/cicd.sh Resolved
With the deploy path now a *.so glob, a failed cargo build-sbf could let the script deploy a .so left over from an earlier build. set -e ends the script at the failed build instead.
pnpm runs package.json scripts through cmd.exe on Windows, which does not expand globs, so 'solana program deploy ./program/target/so/*.so' only worked in POSIX shells. Deploy the file cargo build-sbf actually writes, <crate lib name>.so, in both package.json and cicd.sh.

While checking every deploy path against its crate's artifact name:
- seven native cicd.sh built without --sbf-out-dir and deployed ./program/target/deploy/program.so, which a workspace member never produces; build into ./program/target/so like the rest
- four token-2022 native package.json deployed hello_solana_program.so (copy-paste)
- seven pinocchio cicd.sh used the deprecated --bpf-out-dir; use --sbf-out-dir
- cross-program-invocation/native deployed hand.so / lever.so and program.so; deploy the two crate-named artifacts, with pipefail since cicd.sh pipes into grep
- counter/native README said 'pnpm deploy', which is pnpm's workspace command, not the script
MarkFeder added a commit to MarkFeder/program-examples that referenced this pull request Nov 10, 2026
pnpm runs package.json scripts through cmd.exe on Windows, which does not expand the *.so glob. Name the file cargo build-sbf writes instead, matching solana-foundation#794.
MarkFeder added a commit to MarkFeder/program-examples that referenced this pull request Nov 10, 2026
pnpm runs package.json scripts through cmd.exe on Windows, which does not expand the *.so glob. Name the file cargo build-sbf writes instead, matching solana-foundation#794.
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.

native/pinocchio examples: deploy script points at program.so, which the build never produces

1 participant