Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LD_LIBRARY_PATH contains an empty entry during build #5796

Open
glandium opened this issue Jul 26, 2018 · 3 comments
Open

LD_LIBRARY_PATH contains an empty entry during build #5796

glandium opened this issue Jul 26, 2018 · 3 comments
Labels
A-environment-variables Area: environment variables A-linkage Area: linker issues, dylib, cdylib, shared libraries, so S-triage Status: This issue is waiting on initial triage.

Comments

@glandium
Copy link
Contributor

Originally filed as rust-lang/rust#52693 but as far as I can tell, this is actually cargo's doing:

I was looking at the output of x.py with -vv for $reasons, and noticed that commands run with LD_LIBRARY_PATH set to multiple paths, separated with a colon, which is normal, but the last character is a colon, which effectively adds the current working directory in the list of paths used. This is generally considered bad practice.

FWIW, when LD_LIBRARY_PATH is set before running x.py, its original value ends up at the end of the LD_LIBRARY_PATH that had a trailing colon.

Cc: @alexcrichton

@alexcrichton
Copy link
Member

I think the bug here is actually these lines --

https://github.com/rust-lang/rust/blob/45b48b9b6d70065a16cc119fe934ed342c664c78/src/bootstrap/bootstrap.py#L613-L621

Mind poking at those and seeing if it fixes the issue? If so mind refiling at rust-lang/rust? (or I can reopen the previous bug)

@glandium
Copy link
Contributor Author

I tried that already, and this didn't change anything. Which is why I moved it here.

@ExpHP
Copy link
Contributor

ExpHP commented Jul 30, 2018

First, an important premise: I believe the standard behavior of most applications (at least in the UNIX world) is to treat PATH="" as equivalent to an unset PATH...and likewise for any other PATH-like environment variable.

If this premise is taken to be false, then as far as I can tell there is no problem.

...but! If this premise is taken to be true, then:


The lines in bootstrap.py are clearly wrong in the case where env["LD_LIBRARY_PATH"] == ''. and that issue should be reopened. However, judging from their context, it likely only affects the build of the bootstrap crate.


...and cargo (or the standard library) is also doing things a bit odd, as is easily demonstrated with this:

use std::env;
fn main() {
    println!("{:?}",
        env::split_paths(&env::var("LD_LIBRARY_PATH").unwrap()).collect::<Vec<_>>()
    );
}

(unset LD_LIBRARY_PATH && cargo run) (a truly-unset variable)

[
    "/home/lampam/cpp/throwaway/env/target/debug",
    "/home/lampam/cpp/throwaway/env/target/debug/deps",
    "/home/lampam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib",
    "/home/lampam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib"
]

LD_LIBRARY_PATH= cargo run (merely an empty string)

[
    "/home/lampam/cpp/throwaway/env/target/debug",
    "/home/lampam/cpp/throwaway/env/target/debug/deps",
    "/home/lampam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib",
    "/home/lampam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib",
    ""
]

If I had to guess, this is because cargo itself uses env::split_paths, and env::split_paths("") produces [""].

@ehuss ehuss added A-environment-variables Area: environment variables A-linkage Area: linker issues, dylib, cdylib, shared libraries, so labels Apr 6, 2020
@epage epage added the S-triage Status: This issue is waiting on initial triage. label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-environment-variables Area: environment variables A-linkage Area: linker issues, dylib, cdylib, shared libraries, so S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

5 participants