Summary
lading publish can fail during preflight when a workspace contains tracked nested Cargo.lock files that become stale after lading bump updates package versions.
The observed failure came from rstest-bdd after bumping workspace packages from 0.5.0 to 0.6.0-beta1.
Error
Updating crates.io index
error: cannot update the lock file /data/leynos/Projects/rstest-bdd/crates/rstest-bdd/tests/ui_lints/Cargo.lock because
--locked was passed to prevent this
help: to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
Cause
lading publish runs cargo test --workspace --all-targets as source-workspace preflight before staging.
In rstest-bdd, one integration test shells out to:
cargo clippy --locked --manifest-path tests/ui_lints/Cargo.toml
tests/ui_lints is a nested Cargo workspace with its own tracked Cargo.lock. After lading bump updates path dependency versions, that nested lockfile still contains the old path package versions, so Cargo needs to rewrite it. The nested test passes --locked, so Cargo aborts.
A scratch refresh showed the nested lockfile needed to update the internal path crates from 0.5.0 to 0.6.0-beta1 and add the new tracing dependency set.
Expected Behaviour
Lading should either:
- refresh tracked lockfiles after manifest version/dependency rewrites, including nested lockfiles; or
- fail before the full publish preflight with a targeted diagnostic naming the stale lockfile and the exact repair command.
Proposed Fix
Add lockfile handling to lading:
-
After lading bump, discover tracked Cargo.lock files under the workspace excluding target.
-
For each lockfile whose parent has a Cargo.toml, run:
cargo generate-lockfile --manifest-path <parent>/Cargo.toml
-
In lading publish, add a lockfile freshness validation phase before cargo test:
cargo metadata --locked --manifest-path <parent>/Cargo.toml --format-version=1
-
If Cargo reports that a lockfile cannot be updated because --locked was passed, raise a PublishPreflightError with the lockfile path and the corresponding cargo generate-lockfile --manifest-path ... command.
Further Investigation
lading publish currently runs preflight before staging and patch stripping. That means preflight does not validate the exact tree later used for cargo package and cargo publish.
Investigate whether publish should be split into:
- verify source git cleanliness;
- plan and stage the workspace;
- apply publish-time manifest changes;
- refresh or validate staged lockfiles;
- run cargo preflight in the staged workspace;
- package and publish from the same staged workspace.
This would let dry-run publish repair staged lockfiles without mutating the source checkout.
No code changes were made in either repository during this investigation. The only commands with side effects were in / tmp scratch copies/logs, plus Cargo may have downloaded dependencies while checking the root metadata because the root
lockfile was already locally modified before this investigation.
Summary
lading publishcan fail during preflight when a workspace contains tracked nestedCargo.lockfiles that become stale afterlading bumpupdates package versions.The observed failure came from
rstest-bddafter bumping workspace packages from0.5.0to0.6.0-beta1.Error
Cause
lading publish runs cargo test --workspace --all-targets as source-workspace preflight before staging.
In rstest-bdd, one integration test shells out to:
tests/ui_lints is a nested Cargo workspace with its own tracked Cargo.lock. After lading bump updates path dependency versions, that nested lockfile still contains the old path package versions, so Cargo needs to rewrite it. The nested test passes --locked, so Cargo aborts.
A scratch refresh showed the nested lockfile needed to update the internal path crates from 0.5.0 to 0.6.0-beta1 and add the new tracing dependency set.
Expected Behaviour
Lading should either:
Proposed Fix
Add lockfile handling to lading:
After lading bump, discover tracked Cargo.lock files under the workspace excluding target.
For each lockfile whose parent has a Cargo.toml, run:
In lading publish, add a lockfile freshness validation phase before cargo test:
If Cargo reports that a lockfile cannot be updated because --locked was passed, raise a PublishPreflightError with the lockfile path and the corresponding cargo generate-lockfile --manifest-path ... command.
Further Investigation
lading publish currently runs preflight before staging and patch stripping. That means preflight does not validate the exact tree later used for cargo package and cargo publish.
Investigate whether publish should be split into:
This would let dry-run publish repair staged lockfiles without mutating the source checkout.
No code changes were made in either repository during this investigation. The only commands with side effects were in
/ tmpscratch copies/logs, plus Cargo may have downloaded dependencies while checking the root metadata because the rootlockfile was already locally modified before this investigation.