Skip to content

Commit 54dbc2b

Browse files
committed
fix: Avoid inserting search_path again.
1 parent e888c13 commit 54dbc2b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ impl<'gctx> Compilation<'gctx> {
323323

324324
let dylib_path = paths::dylib_path();
325325
let dylib_path_is_empty = dylib_path.is_empty();
326-
search_path.extend(dylib_path.into_iter());
326+
if dylib_path.starts_with(&search_path) {
327+
search_path = dylib_path;
328+
} else {
329+
search_path.extend(dylib_path.into_iter());
330+
}
327331
if cfg!(target_os = "macos") && dylib_path_is_empty {
328332
// These are the defaults when DYLD_FALLBACK_LIBRARY_PATH isn't
329333
// set or set to an empty string. Since Cargo is explicitly setting

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ fn issue_14194_deduplicate_library_path_env_var() {
21782178
let prev_lib_path = std::fs::read_to_string(txt).unwrap();
21792179
// Ensure no duplicate insertion to dylib search paths
21802180
// when calling `cargo run` recursively.
2181-
assert_ne!(lib_path, prev_lib_path);
2181+
assert_eq!(lib_path, prev_lib_path);
21822182
}}
21832183
21842184
if level == 0 {{

0 commit comments

Comments
 (0)