7
votes

I recently downloaded and unpacked the Rust Language from this site (Linux 64-bit).

I then installed Rust using the given script in the download install.sh:

root@kali:~# /root/rust-1.9.0-x86_64-unknown-linux-gnu/install.sh
install: uninstalling component 'rustc'
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'rust-std-x86_64-unknown-linux-gnu'
install: installing component 'rust-docs'
install: installing component 'cargo'

    Rust is ready to roll.

I am trying to install a crate with cargo, but I keep running into this error:

root@kali:~# cargo install racer
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling winapi v0.2.7
   Compiling bitflags v0.5.0
error: can't find crate for `std` [E0463]
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
error: can't find crate for `std` [E0463]
error: aborting due to previous error
error: failed to compile `racer v1.2.10`, intermediate artifacts can be found at `/root/target-install`

cargo install cargo-edit failed with the same result as above, so it's not limited to one particular package.

Even putting a simple program:

fn main() {
    println!("Hello, world!");
}

in a file named hello.rs and running rustc hello.rs does not compile; it gives the same error: error: can't find crate for 'std' [E0463].

The download came with a directory named rust-std-x86_64-unknown-linux-gnu, which I assume is the std crate. How do I instruct rustc to find this directory when trying to locate the std crate?

1
Can you compile Rust code other than Racer? For example, try cargo install cargo-edit. Although Racer needs the source code of std, the error message sounds like the compiler can't find the std binaries, so it can't even compiler Racer.user395760
@delnan: Apparently even "Hello, world!" does not compile, so I would tend to agree that the issue here is rustc not knowing where the std crate is.Matthieu M.
You could try using rustup.Chris Morgan
@Chris Morgan thanks for suggesting rustup; I'll look in to it!ljeabmreosn

1 Answers

1
votes

The following will work for the simplest of compilations. Assuming you extracted the tar file to, say

$HOME/rust-1.10.0-x86_64-unknown-linux-gnu

Then run

arch=x86_64-unknown-linux-gnu
dl=$HOME/rust-1.10.0-$arch
$dl/rustc/bin/rustc -L $dl/rustc/lib \
    -L $dl/rust-std-$arch/lib/rustlib/$arch/lib \
    hello.rs

But I'm sure a better way would be to run rustup as Chris Morgan suggest.

Coupla more points

  1. You shouldn't compile code as root.
  2. You may have to relogin or run bash -l to get the environment setup by rustup.

(Fellow rust newb here)