publish multiple crates, races with dependencies · Issue #9507 · rust-lang/cargo (original) (raw)
Problem
My project has multiple crates in a cargo workspace. I use a shell loop to run cargo publish on each of the crates in dependency order.
I get output like this:
+ cargo publish --no-verify
Updating crates.io index
Packaging otter-api-tests v0.6.0 (/volatile/rustcargo/Rustup/Game/server/apitest)
Uploading otter-api-tests v0.6.0 (/volatile/rustcargo/Rustup/Game/server/apitest)
nailing-cargo: finished. status 0.
+ nailing-cargo --no-nail --linkfarm=git --- sh -xec
find . ! -type l ! -type d ! -path './target/*' -print0 | xargs -0r rm --
cd wdriver; cargo publish --no-verify
nailing-cargo: out-of-tree, building in: `/home/ian/Rustup/Game/Build/server'
nailing-cargo: using really to run as user `rustcargo'
nailing-cargo: invoking: sh -xec
find . ! -type l ! -type d ! -path './target/*' -print0 | xargs -0r rm --
cd wdriver; cargo publish --no-verify
+ find . ! -type l ! -type d ! -path ./target/* -print0
+ xargs -0r rm --
+ cd wdriver
+ cargo publish --no-verify
Updating crates.io index
Packaging otter-webdriver-tests v0.6.0 (/volatile/rustcargo/Rustup/Game/server/wdriver)
error: failed to prepare local package for uploading
Caused by:
failed to select a version for the requirement `otter-api-tests = "=0.6.0"`
candidate versions found which didn't match: 0.5.1
location searched: crates.io index
required by package `otter-webdriver-tests v0.6.0 (/volatile/rustcargo/Rustup/Game/server/wdriver)`
As you can see, cargo publish
for otter-api-tests v0.6.0
succeeded. But cargo publish
for otter-webdriver-tests
then failed, complaining that otter-api-tests = "=0.6.0"
could not be resolved.
I tried working around this with sleep 10
. That wasn't enough.
I looked in cargo help publish
to see if there was a way to turn off the dependency check, but I didn't see one. I also looked at various commands to see if I could perhaps poll the registry, but nothing seemed relevant. cargo search
seems too dwim, even with postprocessing of the ouptut, and I am not convinced (from my experiences with publishing otter 0.5.1) that this would necessarily work.
Steps
- Make two crates, A and B, where B depends on the precise version of A.
- cd A && cargo publish && cd ../B && cargo publish
Possible Solution(s)
Ideally whatever service cargo publish
talks to wouldn't say "yes" until it had done it. Or maybe cargo publish
could at least have an option to wait.
Notes
Output of cargo version
:
cargo 1.54.0-nightly (e51522ab3 2021-05-07)
I am slightly perplexed since I don't understand how large Rust projects with multiple crates do their publish.