@@ -2147,6 +2147,90 @@ fn crate_library_path_env_var() {
2147
2147
setenv_for_removing_empty_component ( p. cargo ( "run" ) ) . run ( ) ;
2148
2148
}
2149
2149
2150
+ // See https://github.com/rust-lang/cargo/issues/14194
2151
+ #[ cargo_test]
2152
+ fn issue_14194_deduplicate_library_path_env_var ( ) {
2153
+ let p = project ( )
2154
+ . file (
2155
+ "src/main.rs" ,
2156
+ & format ! (
2157
+ r#"
2158
+ use std::process::Command;
2159
+ fn main() {{
2160
+ println!("{{}}", std::env::var("{}").unwrap_or_default());
2161
+ let level: i32 = std::env!("LEVEL").to_string().parse().unwrap();
2162
+ if level == 0 {{
2163
+ return;
2164
+ }}
2165
+
2166
+ let _ = Command::new(std::env!("CARGO"))
2167
+ .arg("run")
2168
+ .env("LEVEL", (level - 1).to_string())
2169
+ .status()
2170
+ .unwrap();
2171
+ }}
2172
+ "# ,
2173
+ dylib_path_envvar( )
2174
+ ) ,
2175
+ )
2176
+ . file (
2177
+ "build.rs" ,
2178
+ & format ! (
2179
+ r#"
2180
+ fn main() {{
2181
+ println!("cargo::rerun-if-env-changed={}");
2182
+ }}
2183
+ "# ,
2184
+ dylib_path_envvar( )
2185
+ ) ,
2186
+ )
2187
+ . build ( ) ;
2188
+
2189
+ setenv_for_removing_empty_component ( p. cargo ( "run" ) )
2190
+ . env ( "LEVEL" , 2 . to_string ( ) )
2191
+ . with_stdout_data ( str![ [ r#"
2192
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2193
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2194
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2195
+
2196
+ "# ] ] )
2197
+ . with_stderr_data ( str![ [ r#"
2198
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2199
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2200
+ [RUNNING] `target/debug/foo`
2201
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2202
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2203
+ [RUNNING] `target/debug/foo`
2204
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2205
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2206
+ [RUNNING] `target/debug/foo`
2207
+
2208
+ "# ] ] )
2209
+ . run ( ) ;
2210
+
2211
+ setenv_for_removing_empty_component ( p. cargo ( "run" ) )
2212
+ . env ( "LEVEL" , 2 . to_string ( ) )
2213
+ . with_stdout_data ( str![ [ r#"
2214
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2215
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2216
+ [ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:[ROOT]/foo/target/debug/deps:[ROOT]/foo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/workspace/cargo/target/debug/build/curl-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libgit2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/build/libnghttp2-sys-[HASH]/out/i/lib:/root/workspace/cargo/target/debug/build/libsqlite3-sys-[HASH]/out:/root/workspace/cargo/target/debug/build/libssh2-sys-[HASH]/out/build:/root/workspace/cargo/target/debug/deps:/root/workspace/cargo/target/debug:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib/rustlib/[HOST_TARGET]/lib:/root/.rustup/toolchains/nightly-[HOST_TARGET]/lib
2217
+
2218
+ "# ] ] )
2219
+ . with_stderr_data ( str![ [ r#"
2220
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2221
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2222
+ [RUNNING] `target/debug/foo`
2223
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2224
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2225
+ [RUNNING] `target/debug/foo`
2226
+ [COMPILING] foo v0.0.1 ([ROOT]/foo)
2227
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2228
+ [RUNNING] `target/debug/foo`
2229
+
2230
+ "# ] ] )
2231
+ . run ( ) ;
2232
+ }
2233
+
2150
2234
// Regression test for #4277
2151
2235
#[ cargo_test]
2152
2236
fn build_with_fake_libc_not_loading ( ) {
0 commit comments