get .crates2.json from $CARGO_HOME if present
This commit is contained in:
@@ -86,8 +86,7 @@ impl Rust {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_crates_file() -> Result<PathBuf> {
|
fn get_crates_file() -> Result<PathBuf> {
|
||||||
let mut result = crate::path::get_home_dir().context("getting home dir")?;
|
let mut result = crate::path::get_cargo_home().context("getting cargo home dir")?;
|
||||||
result.push(".cargo");
|
|
||||||
result.push(".crates2.json");
|
result.push(".crates2.json");
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,22 @@ pub(crate) fn get_pacdef_base_dir() -> Result<PathBuf> {
|
|||||||
Ok(dir)
|
Ok(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the path to the cargo home directory.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// This function will return an error if neither the `$CARGO_HOME` nor
|
||||||
|
/// the `$HOME` environment variables are set.
|
||||||
|
pub(crate) fn get_cargo_home() -> Result<PathBuf> {
|
||||||
|
if let Ok(config) = env::var("CARGO_HOME") {
|
||||||
|
Ok(config.into())
|
||||||
|
} else {
|
||||||
|
let mut config = get_home_dir().context("falling back to $HOME/.cargo")?;
|
||||||
|
config.push(".cargo");
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the path to the XDG config directory.
|
/// Get the path to the XDG config directory.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|||||||
Reference in New Issue
Block a user