Skip to content

Commit ed399ad

Browse files
committed
fix(config): Fallback to non-canonical path for workspace-path-hash
Fixes #16110
1 parent b4a2eb3 commit ed399ad

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/cargo/util/context/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ impl GlobalContext {
710710
.to_string(),
711711
),
712712
("{workspace-path-hash}", {
713-
let real_path = std::fs::canonicalize(workspace_manifest_path)?;
713+
let real_path = std::fs::canonicalize(workspace_manifest_path)
714+
.unwrap_or_else(|_err| workspace_manifest_path.to_owned());
714715
let hash = crate::util::hex::short_hash(&real_path);
715716
format!("{}{}{}", &hash[0..2], std::path::MAIN_SEPARATOR, &hash[2..])
716717
}),

tests/testsuite/script/cargo.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,14 +2197,17 @@ fn memfd_script() {
21972197

21982198
p.cargo(&format!("-Zscript -v /proc/self/fd/{raw_fd}"))
21992199
.masquerade_as_nightly_cargo(&["script"])
2200-
.with_status(101)
2201-
.with_stdout_data(str![""])
2200+
.with_stdout_data(str![[r#"
2201+
current_exe: [ROOT]/home/.cargo/build/[HASH]/target/debug/package
2202+
arg0: /proc/self/fd/[..]
2203+
args: []
2204+
2205+
"#]])
22022206
.with_stderr_data(str![[r#"
22032207
[WARNING] `package.edition` is unspecified, defaulting to `2024`
2204-
2205-
thread 'main' ([..]) panicked at src/cargo/core/workspace.rs:465:18:
2206-
template is correct: [NOT_FOUND]
2207-
[NOTE] run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2208+
[COMPILING] package v0.0.0 (/proc/self/fd/[..])
2209+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2210+
[RUNNING] `[ROOT]/home/.cargo/build/[HASH]/target/debug/package`
22082211
22092212
"#]])
22102213
.run();

0 commit comments

Comments
 (0)