Cargo Add for Dependency Management
Rust
The cargo add [OPTIONS] <DEP> is a useful command that adds dependencies to a Cargo.toml manifest file.
To install:
cargo install cargo-edit
Usage
In the root of your project run:
cargo add serde
This will add the dependency and update your Cargo.toml file.
For full instructions, run cargo add --help.
Git Setup
If you have overridden your access to a remote git service to use SSH rather than HTTPS, you may need to tweak your ~/.gitconfig.
The problem:
cargo add serde
Updating 'https://github.com/rust-lang/crates.io-index' index
Error: failed to acquire username/password from local configuration
Caused by:
failed to acquire username/password from local configuration
The solution - add this to ~/.gitconfig:
# existing github.com override
[url "git@github.com:"]
insteadOf = https://github.com/
# fine-tune the override to avoid issues with cargo-edit
[url "https://github.com/rust-lang/crates.io-index"]
insteadOf = https://github.com/rust-lang/crates.io-index
comments powered by Disqus