Skip to content

Commit 64bd160

Browse files
committed
Don't canonicalize in cargo_exe
1 parent a6c604d commit 64bd160

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/cargo/util/context/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ use crate::sources::CRATES_IO_REGISTRY;
7777
use crate::util::errors::CargoResult;
7878
use crate::util::network::http::configure_http_handle;
7979
use crate::util::network::http::http_handle;
80-
use crate::util::try_canonicalize;
8180
use crate::util::{internal, CanonicalUrl};
8281
use crate::util::{Filesystem, IntoUrl, IntoUrlWithBase, Rustc};
8382
use anyhow::{anyhow, bail, format_err, Context as _};
@@ -457,11 +456,10 @@ impl GlobalContext {
457456
// commands that use Cargo as a library to inherit (via `cargo <subcommand>`)
458457
// or set (by setting `$CARGO`) a correct path to `cargo` when the current exe
459458
// is not actually cargo (e.g., `cargo-*` binaries, Valgrind, `ld.so`, etc.).
460-
let exe = try_canonicalize(
461-
self.get_env_os(crate::CARGO_ENV)
462-
.map(PathBuf::from)
463-
.ok_or_else(|| anyhow!("$CARGO not set"))?,
464-
)?;
459+
let exe = self
460+
.get_env_os(crate::CARGO_ENV)
461+
.map(PathBuf::from)
462+
.ok_or_else(|| anyhow!("$CARGO not set"))?;
465463
Ok(exe)
466464
};
467465

@@ -470,7 +468,7 @@ impl GlobalContext {
470468
// The method varies per operating system and might fail; in particular,
471469
// it depends on `/proc` being mounted on Linux, and some environments
472470
// (like containers or chroots) may not have that available.
473-
let exe = try_canonicalize(env::current_exe()?)?;
471+
let exe = env::current_exe()?;
474472
Ok(exe)
475473
}
476474

@@ -481,8 +479,6 @@ impl GlobalContext {
481479
// Otherwise, it has multiple components and is either:
482480
// - a relative path (e.g., `./cargo`, `target/debug/cargo`), or
483481
// - an absolute path (e.g., `/usr/local/bin/cargo`).
484-
// In either case, `Path::canonicalize` will return the full absolute path
485-
// to the target if it exists.
486482
let argv0 = env::args_os()
487483
.map(PathBuf::from)
488484
.next()

0 commit comments

Comments
 (0)