Cargo and ~/.cargo/config.toml
cargo
searches for its configuration files in a hierarchical
set of paths.
$CARGO_HOME/config.toml
is generally the best place to put global configuration settings,
which typically would include a [registries]
entry specifying the index
url of your private
crate registry. ("global" here means across all projects for a specific user on a given machine.)
Alternatively, cargo
configuration can also be specified inside a crate's source directory,
i.e. for a crate at ~/src/my-crate
, configuration can be set in a file at ~/src/my-crate/.cargo/config.toml
,
which is useful for settings that are specific to a given crate/project.
Tip: A tricky problem to detect is when the cargo
config settings in one file are
overriding the settings in another file unexpectedly. Cargo's documentation about which
paths it searches for configuration files is here.