Search code examples
rustdependenciesrust-cargo

How to use subpackage of nested Cargo.toml git project?


I want to use the package substrate-test-runtime-client from the substrate GitHub repo.

[dependency]
substrate-test-runtime-client = [git = "https://github.com/paritytech/substrate.git", branch = "master"]

Above Cargo.toml syntax doesn't resolve the issue. How can I extract, compile, and use a subpackage of umbrella package.


Solution

  • You are on the right track. You need to use curly brackets to specify an inline TOML table.

    So either add the following to your Cargo.toml file.

    [dependencies]
    substrate-test-runtime-client = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
    

    Or use this which is equivalent

    [dependencies.substrate-test-runtime-client]
    git = "https://github.com/paritytech/substrate.git"
    branch = "master"
    

    Cargo will crawl the downloaded repository looking for a package called substrate-test-runtime-client. See here.