12

I just updated to latest nightly of rust:

> rustc --version
rustc 0.11.0-pre-nightly (05ca9f7 2014-06-24 22:06:48 +0000)
host: x86_64-apple-darwin

After that even the trivial program doesn't compile with the following error:

> cat main.rs

fn main() {
    print!("Hello world");
}%   

> rustc main.rs 
main.rs:1:1: 1:1 error: can't find crate for `std`
main.rs:1 // Playground
          ^
error: aborting due to previous error

Is it some compiler bug in nightly or I didn't grasp some core idea in the language?

4
  • I know nothing of rust, but nightlies are usually far more risky, and if "trivial" code no longer compiles, a bug in the nightly seems exceedingly likely. Commented Jun 25, 2014 at 19:50
  • @MooingDuck Nightlies are usually not bad with rust, this is a rare exception. Try one more time with a different nightly. If this still doesn't work, it may mean deeper problems Commented Jun 25, 2014 at 20:03
  • FWIW, I'm on Linux (same compiler version) and it worked just fine. Maybe this is osx-specific Commented Jun 25, 2014 at 21:05
  • how do you downgrade to an earlier nightly?
    – Patrick
    Commented Jun 25, 2014 at 21:07

3 Answers 3

20

It turned out that if you're upgrading from "semi-stable" version installed with Homebrew, you should first uninstall homebrew version, and only after that install nightly.

Otherwise you'll face the problems that are described in question: missing system libraries, etc, as rust libraries doesn't use versioning and located in the same place.

2
  • 2
    That was exactly my problem
    – talles
    Commented Sep 6, 2014 at 13:57
  • additionally, after removing homebrew version of rust, don't forget to uninstall previous rust version you may have, and only then install new using official rust installation script.
    – Developer
    Commented Oct 10, 2015 at 16:16
2

In general, this means that there are multiple versions of the standard library lying around. Try reinstalling, or uninstalling and then installing again, to clear it up.

1

I encountered the same error when trying to get Rust to work on a Fedora system using the packages provided by the Fedora repo.

It turns out I too had an old version of Rust installed (via rustup). I did remove it prior to installing the Rust packages with DNF, but I still got the error: can't find crate for `std` error. This bug report pointed me in the right direction.

Turns out I had an empty /usr/lib64/rustlib directory as a remnant from the previous install (whereas the correct one is /usr/lib/rustlib). Removing it resolved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.