Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if CARGO_TARGET_DIR is an empty string #8939

Merged
merged 6 commits into from
Feb 25, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ impl Config {
if let Some(dir) = &self.target_dir {
Ok(Some(dir.clone()))
} else if let Some(dir) = env::var_os("CARGO_TARGET_DIR") {
if dir.to_str().unwrap().trim() == "" {
anyhow::bail!("The CARGO_TARGET_DIR environment variable is an empty string. Try adding the target directory name to it or deleting the variable.")
Andy-Python-Programmer marked this conversation as resolved.
Show resolved Hide resolved
}

Ok(Some(Filesystem::new(self.cwd.join(dir))))
} else if let Some(val) = &self.build_config()?.target_dir {
let val = val.resolve_path(self);
Expand Down