big_gie
big_gie

Reputation: 3017

Is it possible to migrate data from one cargo crate registry to another?

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

Answers (1)

Caesar
Caesar

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 publishing 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

Related Questions