Skip to content

Commit

Permalink
Merge pull request #220 from deg4uss3r/cargo_home_fix
Browse files Browse the repository at this point in the history
Removed the always matching blank string for the CARGO_HOME variable which fixes an error users were seeing when running `cargo-outdated` and not setting the `CARGO_HOME` environment variable (`rustup` shims always set it for you).
  • Loading branch information
Ricky authored May 5, 2020
2 parents 8fff533 + 83b2285 commit e6085e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-outdated"
version = "0.9.9"
version = "0.9.10"
authors = [
"Kevin K. <[email protected]>",
"Frederick Z. <[email protected]>",
Expand Down
10 changes: 7 additions & 3 deletions src/cargo_ops/temp_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,13 +654,17 @@ fn manifest_paths(elab: &ElaborateWorkspace<'_>) -> CargoResult<Vec<PathBuf>> {
visited.insert(pkg_id);
let pkg = &elab.pkgs[&pkg_id];
let pkg_path = pkg.root().to_string_lossy();

// Checking if there's a CARGO_HOME set and that it is not an empty string
let cargo_home_path = match std::env::var_os("CARGO_HOME") {
Some(path) => path.into_string().expect("Error getting string from OsString"),
None => "".to_string(),
Some(path) if !path.is_empty() => Some(path.into_string().expect("Error getting string from OsString")),
_ => None,
};

// If there is a CARGO_HOME make sure we do not crawl the registry for more Cargo.toml files
// Otherwise add all Cargo.toml files to the manifest paths
if pkg_path.starts_with(workspace_path) {
if !pkg_path.starts_with(&cargo_home_path){
if cargo_home_path.is_none() || !pkg_path.starts_with(&cargo_home_path.expect("Error extracting CARGO_HOME string")) {
manifest_paths.push(pkg.manifest_path().to_owned());
}
}
Expand Down

0 comments on commit e6085e5

Please sign in to comment.