Skip to content

zombienet-sdk-tests: fall back gracefully when CARGO_WORKSPACE_ROOT_DIR is unset#12611

Open
Thiago316316 wants to merge 6 commits into
paritytech:masterfrom
Thiago316316:t55844/udeps-zombienet-sdk-tests-fix
Open

zombienet-sdk-tests: fall back gracefully when CARGO_WORKSPACE_ROOT_DIR is unset#12611
Thiago316316 wants to merge 6 commits into
paritytech:masterfrom
Thiago316316:t55844/udeps-zombienet-sdk-tests-fix

Conversation

@Thiago316316

@Thiago316316 Thiago316316 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fixes the panic reported in #6906: build.rs unwraps CARGO_WORKSPACE_ROOT_DIR, an env var only supplied by this repo's .cargo/config.toml — absent in environments that don't apply it (e.g. remote-build tooling)

Root cause: build.rs had env::var("CARGO_WORKSPACE_ROOT_DIR").unwrap(). That variable isn't a cargo built-in — it only exists because this repo's .cargo/config.toml defines it under [env]:
CARGO_WORKSPACE_ROOT_DIR = { value = "", relative = true }
Cargo applies [env] entries automatically for a normal in-tree build, which is why it works for most of us locally. Your build path (/home/bkontur/cargo-remote-builds-aaa/...) looks like a remote-build tool that snapshots the source elsewhere and builds it there — in that kind of setup .cargo/config.toml's [env] section isn't necessarily applied, so the var is genuinely absent, and the old code just panicked instead of handling that.

What I confirmed before writing the fix:

  • Reproduced your exact panic locally, by temporarily disabling .cargo/config.toml and clearing the crate's generated metadata files (so build.rs couldn't skip past the code path that needs the var).
  • Confirmed via cargo tree that this variable is used in exactly one place (find_wasm()), and it's only ever an optimization — "if a runtime wasm blob is already built somewhere, reuse it instead of rebuilding" — so it's safe to degrade gracefully instead of panicking.

The fix: workspace_root() (new function on build.rs) now tries CARGO_WORKSPACE_ROOT_DIR first (unchanged behavior when it's present), and if that's absent, derives the workspace root by walking up from CARGO_MANIFEST_DIR — which cargo guarantees unconditionally for every build script — looking for the top-level Cargo.toml that contains [workspace]. That mirrors what cargo itself does to find a workspace root, so it doesn't depend on this crate's fixed depth in the tree.

Closes #6906.

Thiago316316 and others added 4 commits July 8, 2026 22:57
…IR is unset

build.rs previously called env::var("CARGO_WORKSPACE_ROOT_DIR").unwrap(),
which only resolves because .cargo/config.toml defines it under [env].
Environments that don't apply that config (e.g. remote-build tooling)
panic instead. workspace_root() now falls back to walking up from
CARGO_MANIFEST_DIR, which cargo guarantees unconditionally, to find the
workspace root by locating the top-level [workspace] Cargo.toml.

Part of paritytech#6906.
@Thiago316316 Thiago316316 marked this pull request as ready for review July 9, 2026 02:20
@Thiago316316

Copy link
Copy Markdown
Contributor Author

@bkontur Would appreciate a look when you have a chance — and if you're able to, a T18-zombienet_tests label would help it clear CI's check-labels gate.

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.

cargo udeps check

1 participant