Skip to content

fix: fall back to package.json for CLI version detection#21382

Merged
PhilWindle merged 1 commit into
merge-train/spartanfrom
claudebox/fix-aztec-version-unknown
Mar 12, 2026
Merged

fix: fall back to package.json for CLI version detection#21382
PhilWindle merged 1 commit into
merge-train/spartanfrom
claudebox/fix-aztec-version-unknown

Conversation

@AztecBot
Copy link
Copy Markdown
Collaborator

@AztecBot AztecBot commented Mar 11, 2026

Summary

Fixes aztec --version returning unknown when installed via install.aztec-labs.com.

Closes https://linear.app/aztec-labs/issue/A-642/aztec-version-returns-unkonwn

ClaudeBox log: https://claudebox.work/s/9b17d34db367f45c?run=1

@AztecBot AztecBot added the claudebox Owned by claudebox. it can push to this PR. label Mar 11, 2026
@ludamad ludamad marked this pull request as ready for review March 11, 2026 19:13
@PhilWindle PhilWindle changed the base branch from next to merge-train/spartan March 12, 2026 10:19
@PhilWindle PhilWindle merged commit 893be0c into merge-train/spartan Mar 12, 2026
46 of 49 checks passed
@PhilWindle PhilWindle deleted the claudebox/fix-aztec-version-unknown branch March 12, 2026 10:20
AztecBot added a commit that referenced this pull request Mar 12, 2026
## Summary

Fixes `aztec --version` returning `unknown` when installed via `install.aztec-labs.com`.

Closes https://linear.app/aztec-labs/issue/A-642/aztec-version-returns-unkonwn

ClaudeBox log: https://claudebox.work/s/9b17d34db367f45c?run=1
@AztecBot
Copy link
Copy Markdown
Collaborator Author

✅ Successfully backported to backport-to-v4-staging #21410.

ludamad added a commit that referenced this pull request Mar 12, 2026
BEGIN_COMMIT_OVERRIDE
fix: fall back to package.json for CLI version detection (#21382)
chore: Removed multiplier config (#21412)
chore: Removed default snapshot url config (#21413)
chore: Read tx filestores from network config (#21416)
feat(p2p): use l2 priority fee only for tx priority (#21420)
fix: update private kernel reset hints builder (#20760)
END_COMMIT_OVERRIDE
github-merge-queue Bot pushed a commit that referenced this pull request Mar 16, 2026
BEGIN_COMMIT_OVERRIDE
feat: add ETHEREUM_HTTP_TIMEOUT_MS env var for viem HTTP transport
(#20919)
fix(archiver): filter tagged log queries by block number (#21388)
fix(node): handle slot zero in getL2ToL1Messages (#21386)
feat(sequencer): redistribute checkpoint budget evenly across remaining
blocks (#21378)
fix: fall back to package.json for CLI version detection (#21382)
chore: Removed multiplier config (#21412)
chore: Removed default snapshot url config (#21413)
chore: Read tx filestores from network config (#21416)
fix(node): check world state against requested block hash (#21385)
feat(p2p): use l2 priority fee only for tx priority (#21420)
feat(p2p): reject and evict txs with insufficient max fee per gas
(#21281)
revert "feat(p2p): reject and evict txs with insufficient max fee per
gas (#21281)" (#21432)
chore: Reduce log spam (#21436)
fix(tx): reject txs with invalid setup when unprotecting (#21224)
fix: orchestrator enqueue yield (#21286)
chore(builder): check archive tree next leaf index during block building
(#21457)
fix: scenario deployment (#21428)
chore: add claude skill to read network-logs (#21495)
chore: update claude network-logs skill (#21523)
feat(rpc): add package version to RPC response headers (#21526)
chore(prover): silence "epoch to prove" debug logs (#21527)
chore(sequencer): do not log blob data (#21530)
fix: dependabot alerts (#21531)
docs(p2p): nicer READMEs (#21456)
fix(archiver): guard getL1ToL2Messages against incomplete message sync
(#21494)
fix(sequencer): await syncing proposed block to archiver (#21554)
feat(ethereum): check VK tree root and protocol contracts hash in rollup
compatibility (#21537)
fix: marking peer as dumb on failed responses (#21316)
fix(kv-store): make LMDB clear and drop operations atomic across
sub-databases (#21539)
feat(world-state): add blockHash verification to syncImmediate (#21556)
chore(monitor): print out l2 fees components (#21559)
chore: rm faucet (#21538)
chore: remove old merkle trees (#21577)
feat: Implement commit all and revert all for world state checkpoints
(#21532)
chore: skip flaky browser acir tests in CI (#21596)
fix: Better detection for epoch prune (#21478)
chore: logging (#21604)
fix: Don't update state if we failed to execute sufficient transactions
(#21443)
END_COMMIT_OVERRIDE
return version;
}
} catch {
// No package.json found either.
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.

@ludamad I would ping you about this on slack but at this point I don't know how so asking here.

2 things seem strange to me in this function:

  1. We are getting the version here from .release-please-manifest.json which seems strange given that release please is deprecated. Also it doesn't seem to correctly resolve the specific version (e.g. a given nightly) and instead it just resolves the future stable version (e.g. currently 4.3.0 on v4).
  2. When we don't find the package.json we don't error out and instead we just return undefined.

Given these 2 problems I implemented my own function in this PR that looks as follows:

/**
 * Returns the package version for embedding in contract artifacts or `dev` if the version in package.json is
 * the placeholder value (that would indicate that this is used from a locally checked out monorepo instead of npm).
 */
function getPackageVersionOrDev(): string {
  const dir = dirname(fileURLToPath(import.meta.url));
  const packageJsonPath = resolve(dir, '../../../package.json');
  const version = JSON.parse(readFileSync(packageJsonPath).toString()).version;
  return version === '0.1.0' ? DEV_VERSION : version;
}

What this does is that it returns the version from package.json or "dev" string when the code is run froms a checked out monorepo and not a real release.

I think we should replace the getPackageVersion function with my implementation.

(and maybe drop the .release-please-manifest.json file)

Would you agree?

Copy link
Copy Markdown
Contributor

@benesjan benesjan May 5, 2026

Choose a reason for hiding this comment

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

AI feedback

Agree with the diagnosis, broadly agree with the replacement, but a few wrinkles before wholesale replacing it.

On the diagnosis — yes:

  • .release-please-manifest.json currently holds 5.0.0 in this checkout. That's the next stable target, not the actually-installed/built version. So for nightlies and stable releases the manifest reading is straight-up wrong; package.json (which release tooling stamps at publish time) is the right source.
  • Returning undefined forces every caller into ?? '<fallback>' ('', 'unknown', '0.0.0' — all different, none ideal). A typed string is cleaner.

Wrinkles to think about before swapping:

  1. Path depth. Your snippet uses ../../../package.json but the existing fallback in this file uses ../../package.json. For dest/update-checker/package_version.js in the published stdlib package, ../../ is the package root. Make sure the depth in feat: stamping aztec version into contract artifacts #22550 matches the file's actual location, not a copy-paste from elsewhere.

  2. Caller behavior change in dev. Today, in a repo checkout, every caller sees 5.0.0. After the change they'll see 'dev'. Mostly fine, but warn_if_aztec_version_mismatch.ts builds expectedTag = \v${version}`'vdev'and will then warn on every aztec-nr dep. That caller needs an explicitif (version === DEV_VERSION) return;` guard.

  3. Other callers of ?? ''. aztec-node/server.ts etc. compare versions across the network — if the node reports 'dev', downstream comparisons should treat that explicitly rather than as "just another version string." Worth a pass.

  4. Don't delete .release-please-manifest.json in this PR. Even if release-please is deprecated, that file may still be consumed by current release tooling / GH actions. Confirm it's actually unused first; it's a separate, riskier change from "stop reading it from JS."

  5. Naming. getPackageVersionOrDev is fine, but since you're replacing the canonical one, I'd just keep getPackageVersion(): string (always-returns-a-string semantics, with 'dev' baked in) so callers don't need to know the suffix. The behavior is now "the package version, or DEV_VERSION for unstamped checkouts."

So: yes, replace it. But fold the dev guard into the version-mismatch warner in the same PR, double-check the path depth, and split off the manifest-file deletion.

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.

Decided to go ahead and tackled this in #22941

benesjan added a commit that referenced this pull request May 5, 2026
[This other
PR](#22941) of mine
was motivation for this because there we need to stamp aztec version
into contract artifact and the current `getPackageVersion` was not
helpful in that because it failed to resolve the actual version (e.g.
`v4.3.0-nightly.20260427` instead of `v4.3.0`). To workaround this I
will no longer read the version from `.release-please-manifest.json` and
will read it from package.json instead where the version is stamped
during a release. If the code is not run from a release the version is
simply populated with "dev" which seems better then returning undefined
and forcing the callsites to deal with it.

Bothering Adam and Alex with a review here since you are the only people
that seemed to have touched the function.

## AI  Summary

- `getPackageVersion` previously read from
`.release-please-manifest.json`, which holds the *next* stable target
(currently `5.0.0`) — not the actually-installed/built version. So
nightlies and stable releases reported a stale version.
- It now reads from the stdlib `package.json` (which release tooling
stamps at publish time) and substitutes `DEV_VERSION` (`'dev'`) for the
`0.1.0` placeholder used in a monorepo checkout.
- Return type narrowed from `string | undefined` to `string`, and the
now-dead `?? '<fallback>'` chains in callers (`aztec-node`, `aztec` CLI,
`cli-wallet`, `txe`) are dropped.
- `warnIfAztecVersionMismatch` gets an early return on `DEV_VERSION` so
monorepo checkouts no longer spam warnings about every aztec-nr dep tag
mismatch (previously it would compare against `v5.0.0`, now it would
have compared against `vdev` — both wrong).

`.release-please-manifest.json` is left in place for now since release
tooling may still consume it; removing it can be a separate change.

Context from #21382 review thread:
https://github.com/AztecProtocol/aztec-packages/pull/21382/files#r3182335186
AztecBot pushed a commit that referenced this pull request May 5, 2026
[This other
PR](#22941) of mine
was motivation for this because there we need to stamp aztec version
into contract artifact and the current `getPackageVersion` was not
helpful in that because it failed to resolve the actual version (e.g.
`v4.3.0-nightly.20260427` instead of `v4.3.0`). To workaround this I
will no longer read the version from `.release-please-manifest.json` and
will read it from package.json instead where the version is stamped
during a release. If the code is not run from a release the version is
simply populated with "dev" which seems better then returning undefined
and forcing the callsites to deal with it.

Bothering Adam and Alex with a review here since you are the only people
that seemed to have touched the function.

## AI  Summary

- `getPackageVersion` previously read from
`.release-please-manifest.json`, which holds the *next* stable target
(currently `5.0.0`) — not the actually-installed/built version. So
nightlies and stable releases reported a stale version.
- It now reads from the stdlib `package.json` (which release tooling
stamps at publish time) and substitutes `DEV_VERSION` (`'dev'`) for the
`0.1.0` placeholder used in a monorepo checkout.
- Return type narrowed from `string | undefined` to `string`, and the
now-dead `?? '<fallback>'` chains in callers (`aztec-node`, `aztec` CLI,
`cli-wallet`, `txe`) are dropped.
- `warnIfAztecVersionMismatch` gets an early return on `DEV_VERSION` so
monorepo checkouts no longer spam warnings about every aztec-nr dep tag
mismatch (previously it would compare against `v5.0.0`, now it would
have compared against `vdev` — both wrong).

`.release-please-manifest.json` is left in place for now since release
tooling may still consume it; removing it can be a separate change.

Context from #21382 review thread:
https://github.com/AztecProtocol/aztec-packages/pull/21382/files#r3182335186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4 claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants