Cargo Configuration
Configure Cargo for package management in Rust projects.
Prerequisites
- Rust Setup - Install Rust and Cargo
- Artifactory Setup - Get Artifactory credentials (for Artifactory configuration)
Verify Installation
# Check Cargo version
cargo --version
Artifactory
Configure Cargo to use JFrog Artifactory. Requires Artifactory Setup.
- Windows
- macOS
- Linux
Edit %USERPROFILE%\.cargo\config.toml:
[registries.artifactory]
index = "sparse+https://your-org.jfrog.io/artifactory/api/cargo/cargo-virtual/index/"
[registry]
default = "artifactory"
[net]
git-fetch-with-cli = true
Set credentials:
[System.Environment]::SetEnvironmentVariable("CARGO_REGISTRIES_ARTIFACTORY_TOKEN", "Bearer $env:ARTIFACTORY_IDENTITY_TOKEN", "User")
Edit ~/.cargo/config.toml:
[registries.artifactory]
index = "sparse+https://your-org.jfrog.io/artifactory/api/cargo/cargo-virtual/index/"
[registry]
default = "artifactory"
[net]
git-fetch-with-cli = true
Add to ~/.zshrc:
export CARGO_REGISTRIES_ARTIFACTORY_TOKEN="Bearer $ARTIFACTORY_IDENTITY_TOKEN"
Reload your shell:
source ~/.zshrc
Edit ~/.cargo/config.toml:
[registries.artifactory]
index = "sparse+https://your-org.jfrog.io/artifactory/api/cargo/cargo-virtual/index/"
[registry]
default = "artifactory"
[net]
git-fetch-with-cli = true
Add to ~/.bashrc:
export CARGO_REGISTRIES_ARTIFACTORY_TOKEN="Bearer $ARTIFACTORY_IDENTITY_TOKEN"
Reload your shell:
source ~/.bashrc
Verify Configuration
# Test Cargo access
cargo search serde