Search code examples
rustdependenciesrust-cargo

How to use a crate from a cargo workspace on github as a dependency?


Within the crates directory of the repo, there are sui-keys, sui-core, and others. Within my Cargo.toml file, how do I specify that I want the sui-keys crate as a dependency to my own crate?

[dependencies.sui-keys]
sui-keys = { git = "https://github.com/MystenLabs/sui" }

The above doesn't work.


Solution

  • You have a "sui-keys" too many in there, either remove it from the section header:

    [dependencies]
    sui-keys = { git = "https://github.com/MystenLabs/sui" }
    

    or directly provide the contents for dependencies.sui-keys:

    [dependencies.sui-keys]
    git = "https://github.com/MystenLabs/sui"
    

    I would avoid such mistakes by letting cargo figure it all out:

    cargo add --git="https://github.com/MystenLabs/sui" sui-keys