mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Don't canonicalize in cargo_exe
This commit is contained in:
parent
a6c604d1b8
commit
d82b596962
@ -77,7 +77,6 @@ use crate::sources::CRATES_IO_REGISTRY;
|
|||||||
use crate::util::errors::CargoResult;
|
use crate::util::errors::CargoResult;
|
||||||
use crate::util::network::http::configure_http_handle;
|
use crate::util::network::http::configure_http_handle;
|
||||||
use crate::util::network::http::http_handle;
|
use crate::util::network::http::http_handle;
|
||||||
use crate::util::try_canonicalize;
|
|
||||||
use crate::util::{internal, CanonicalUrl};
|
use crate::util::{internal, CanonicalUrl};
|
||||||
use crate::util::{Filesystem, IntoUrl, IntoUrlWithBase, Rustc};
|
use crate::util::{Filesystem, IntoUrl, IntoUrlWithBase, Rustc};
|
||||||
use anyhow::{anyhow, bail, format_err, Context as _};
|
use anyhow::{anyhow, bail, format_err, Context as _};
|
||||||
@ -457,11 +456,10 @@ impl GlobalContext {
|
|||||||
// commands that use Cargo as a library to inherit (via `cargo <subcommand>`)
|
// commands that use Cargo as a library to inherit (via `cargo <subcommand>`)
|
||||||
// or set (by setting `$CARGO`) a correct path to `cargo` when the current exe
|
// or set (by setting `$CARGO`) a correct path to `cargo` when the current exe
|
||||||
// is not actually cargo (e.g., `cargo-*` binaries, Valgrind, `ld.so`, etc.).
|
// is not actually cargo (e.g., `cargo-*` binaries, Valgrind, `ld.so`, etc.).
|
||||||
let exe = try_canonicalize(
|
let exe = self
|
||||||
self.get_env_os(crate::CARGO_ENV)
|
.get_env_os(crate::CARGO_ENV)
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.ok_or_else(|| anyhow!("$CARGO not set"))?,
|
.ok_or_else(|| anyhow!("$CARGO not set"))?;
|
||||||
)?;
|
|
||||||
Ok(exe)
|
Ok(exe)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -470,7 +468,7 @@ impl GlobalContext {
|
|||||||
// The method varies per operating system and might fail; in particular,
|
// The method varies per operating system and might fail; in particular,
|
||||||
// it depends on `/proc` being mounted on Linux, and some environments
|
// it depends on `/proc` being mounted on Linux, and some environments
|
||||||
// (like containers or chroots) may not have that available.
|
// (like containers or chroots) may not have that available.
|
||||||
let exe = try_canonicalize(env::current_exe()?)?;
|
let exe = env::current_exe()?;
|
||||||
Ok(exe)
|
Ok(exe)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,8 +479,6 @@ impl GlobalContext {
|
|||||||
// Otherwise, it has multiple components and is either:
|
// Otherwise, it has multiple components and is either:
|
||||||
// - a relative path (e.g., `./cargo`, `target/debug/cargo`), or
|
// - a relative path (e.g., `./cargo`, `target/debug/cargo`), or
|
||||||
// - an absolute path (e.g., `/usr/local/bin/cargo`).
|
// - an absolute path (e.g., `/usr/local/bin/cargo`).
|
||||||
// In either case, `Path::canonicalize` will return the full absolute path
|
|
||||||
// to the target if it exists.
|
|
||||||
let argv0 = env::args_os()
|
let argv0 = env::args_os()
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.next()
|
.next()
|
||||||
|
@ -181,12 +181,9 @@ fn custom_build_env_vars() {
|
|||||||
)
|
)
|
||||||
.file("bar/src/lib.rs", "pub fn hello() {}");
|
.file("bar/src/lib.rs", "pub fn hello() {}");
|
||||||
|
|
||||||
let cargo = cargo_exe().canonicalize().unwrap();
|
let cargo = cargo_exe();
|
||||||
let cargo = cargo.to_str().unwrap();
|
let cargo = cargo.to_str().unwrap();
|
||||||
let rustc = paths::resolve_executable("rustc".as_ref())
|
let rustc = paths::resolve_executable("rustc".as_ref()).unwrap();
|
||||||
.unwrap()
|
|
||||||
.canonicalize()
|
|
||||||
.unwrap();
|
|
||||||
let rustc = rustc.to_str().unwrap();
|
let rustc = rustc.to_str().unwrap();
|
||||||
let file_content = format!(
|
let file_content = format!(
|
||||||
r##"
|
r##"
|
||||||
|
@ -375,7 +375,7 @@ fn cargo_subcommand_env() {
|
|||||||
p.cargo("build").run();
|
p.cargo("build").run();
|
||||||
assert!(p.bin("cargo-envtest").is_file());
|
assert!(p.bin("cargo-envtest").is_file());
|
||||||
|
|
||||||
let cargo = cargo_exe().canonicalize().unwrap();
|
let cargo = cargo_exe();
|
||||||
let mut path = path();
|
let mut path = path();
|
||||||
path.push(target_dir.clone());
|
path.push(target_dir.clone());
|
||||||
let path = env::join_paths(path.iter()).unwrap();
|
let path = env::join_paths(path.iter()).unwrap();
|
||||||
@ -388,9 +388,7 @@ fn cargo_subcommand_env() {
|
|||||||
// Check that subcommands inherit an overridden $CARGO
|
// Check that subcommands inherit an overridden $CARGO
|
||||||
let envtest_bin = target_dir
|
let envtest_bin = target_dir
|
||||||
.join("cargo-envtest")
|
.join("cargo-envtest")
|
||||||
.with_extension(std::env::consts::EXE_EXTENSION)
|
.with_extension(std::env::consts::EXE_EXTENSION);
|
||||||
.canonicalize()
|
|
||||||
.unwrap();
|
|
||||||
let envtest_bin = envtest_bin.to_str().unwrap();
|
let envtest_bin = envtest_bin.to_str().unwrap();
|
||||||
// Previously, `$CARGO` would be left at `envtest_bin`. However, with the
|
// Previously, `$CARGO` would be left at `envtest_bin`. However, with the
|
||||||
// fix for #15099, `$CARGO` is now overwritten with the path to the current
|
// fix for #15099, `$CARGO` is now overwritten with the path to the current
|
||||||
@ -623,8 +621,6 @@ fn overwrite_cargo_environment_variable() {
|
|||||||
let stderr_cargo = format!(
|
let stderr_cargo = format!(
|
||||||
"{}[EXE]\n",
|
"{}[EXE]\n",
|
||||||
cargo_exe
|
cargo_exe
|
||||||
.canonicalize()
|
|
||||||
.unwrap()
|
|
||||||
.with_extension("")
|
.with_extension("")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -648,8 +644,6 @@ fn overwrite_cargo_environment_variable() {
|
|||||||
let stderr_other_cargo = format!(
|
let stderr_other_cargo = format!(
|
||||||
"{}[EXE]\n",
|
"{}[EXE]\n",
|
||||||
other_cargo_path
|
other_cargo_path
|
||||||
.canonicalize()
|
|
||||||
.unwrap()
|
|
||||||
.with_extension("")
|
.with_extension("")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -3890,8 +3890,6 @@ fn cargo_test_env() {
|
|||||||
let cargo = format!(
|
let cargo = format!(
|
||||||
"{}[EXE]",
|
"{}[EXE]",
|
||||||
cargo_exe()
|
cargo_exe()
|
||||||
.canonicalize()
|
|
||||||
.unwrap()
|
|
||||||
.with_extension("")
|
.with_extension("")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -3913,8 +3911,6 @@ test env_test ... ok
|
|||||||
let stderr_other_cargo = format!(
|
let stderr_other_cargo = format!(
|
||||||
"{}[EXE]",
|
"{}[EXE]",
|
||||||
other_cargo_path
|
other_cargo_path
|
||||||
.canonicalize()
|
|
||||||
.unwrap()
|
|
||||||
.with_extension("")
|
.with_extension("")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user