Reputation: 3017
I need to migrate from one rust cargo alternative registry (i.e. not crates.io) to another (unrelated) one.
Many crates have been published in the current alternate registry, and many of them depend on both crates.io and the alternate registry (through registry = "..."
key in Cargo.toml
).
Is there a defined way to migrate the crates from the first alternate registry to the second? If not, what would be the best approach for this migration?
Upvotes: 4
Views: 116
Reputation: 8544
If you have a list of crates and versions, downloading them all from $registry/api/v1/crates/$crate/$version/download
, unpacking them, editing registries = …
with sed or a small rust-snippet based on toml-edit, and then re-cargo publish
ing them should do. (Maybe an additional mv Cargo.toml.orig Cargo.toml
is nice.) The only complication I can think of is that the build done by cargo publish
might fail unless you re-publish in the order the crates were originally published. If you like to live dangerously, you can skip that with --no-verify
, but unless you can delete crates from your target registry (i.e. roll back a failed migration attempt), I would avoid that.
Upvotes: 1