Skip to content

"can't find crate for std" error when rustc is a symlink #11713

Closed
@bnoordhuis

Description

@bnoordhuis

With the current HEAD of master (commit 505572b), when I install rust to my home directory and symlink rustc in $HOME/bin (which is on my $PATH), I get the following error:

$ ./configure --prefix=$HOME/opt/rust && make install
# elided

$ echo 'fn main() {}' > t.rs

$ RUST_LOG=rustc::metadata rustc t.rs 
using sysroot = /Users/bnoordhuis
resolving extern mod stmt. ident: @"std" path_opt: Some((@"std#0.10-pre", CookedStr))
filesearch: searching additional lib search paths [0u]
filesearch: searching target lib path
searching /Users/bnoordhuis/lib/rustlib/x86_64-apple-darwin/lib
is /Users/bnoordhuis/src/rust/.rust/lib/x86_64-apple-darwin in visited_dirs? false
searching /Users/bnoordhuis/src/rust/.rust/lib/x86_64-apple-darwin
is /Users/bnoordhuis/src/rust/lib/x86_64-apple-darwin in visited_dirs? false
searching /Users/bnoordhuis/src/rust/lib/x86_64-apple-darwin
t.rs:1:1: 1:1 error: can't find crate for `std`
t.rs:1 fn main() {}
       ^

Invoking rustc as $HOME/opt/rust/bin/rustc fixes it as does linking with -L$HOME/opt/rust/lib/rustlib/x86_64-apple-darwin/lib.

I suspect that rustc is looking for the libraries relative to dirname(argv[0]). That should probably be dirname(realpath(argv[0])).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions