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

Cargo uses "its rustc" rather than the one mandated by the rustup toolchain #809

Closed
japaric opened this issue Nov 14, 2016 · 4 comments
Closed

Comments

@japaric
Copy link
Member

japaric commented Nov 14, 2016

There's this text in the README:

Because the rust-lang/rust tree does not include Cargo, when cargo is invoked for a custom toolchain and it is not available, rustup will attempt to use cargo from one of the release channels, preferring 'nightly', then 'beta' or 'stable'.

And rustup does what it says: It uses e.g. stable Cargo if the custom toolchain doesn't include a Cargo but that Cargo uses e.g. stable rustc rather than the rustc in the custom toolchain.

I think this is a regression because I remember this used to "work". As in Cargo used the custom toolchain rustc.

STR

Sorry this is a little convoluted but avoids having to bootstrap a new rustc to show tho bug:

# Install and switch to the nightly toolchain
$ rustup default nightly

# Create a "custom" toolchain which is actually just the nightly toolchain minus Cargo
$ mkdir -p ~/tmp && cd $_

$ cp -r $(rustc --print sysroot)/../nightly-x86_64-unknown-linux-gnu .

$ rm nightly-x86_64-unknown-linux-gnu/bin/cargo

$ rustup toolchain link custom nightly-x86_64-unknown-linux-gnu

# Install and switch to the stable toolchain
$ rustup default stable

# Remove the nightly toolchain
# (to make rustup fall back to stable Cargo rather than to the nightly Cargo)
$ rustup toolchain remove nightly

# Switch to the custom toolchain
$ rustup toolchain default custom

# Finally, show the bug
$ cargo new --bin app && cd $_

$ edit src/main.rs && cat $_
#![feature(no_core)]
fn main() {
    println!("Hello, world!");
}

# custom (nightly) rustc
$ rustc -V
rustc 1.14.0-nightly (cae6ab1c4 2016-11-05)

# stable Cargo
$ cargo -V
cargo 0.13.0-nightly (eca9e15 2016-11-01)

# Cargo uses the STABLE rustc rather than the "custom" rustc!
$ cargo build
   Compiling app v0.1.0 (file:///home/japaric/tmp/app)
error[E0554]: #[feature] may not be used on the stable release channel
 --> src/main.rs:1:1
  |
1 | #![feature(no_core)]
  | ^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `app`.

To learn more, run the command again with --verbose.

cc @brson

@brson
Copy link
Contributor

brson commented Nov 14, 2016

I think this is a result of #707, making the proxies prepend to PATH, the toolchain path and CARGO_HOME, instead of appending CARGO_HOME then the toolchain path, which was trying to fix #475, making rustup work when CARGO_HOME is not set.

The bug is that by prepending the toolchain path in front of CARGO_HOME, subsequent toolchain invocations are calling the (wrong) toolchain directly, instead of going through the rustup wrapper.

The solution here I think is to change the prepend order, CARGO_HOME first, then the toolchain directory.

@michaelwoerister
Copy link
Member

As a workaround, one can copy a nightly Cargo executable into the bin folder of the custom toolchain.

brson added a commit to brson/rustup.rs that referenced this issue Nov 15, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
brson added a commit to brson/rustup.rs that referenced this issue Nov 17, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
@oli-obk
Copy link
Contributor

oli-obk commented Nov 19, 2016

just a different symptom of the same issue:

error while loading shared libraries: librustc_driver-fbb47b4392bde8ce.so: cannot open shared object file: No such file or directory

leaving this here so others with similar issues can find this issue

brson added a commit to brson/rustup.rs that referenced this issue Nov 22, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
brson added a commit to brson/rustup.rs that referenced this issue Nov 22, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
brson added a commit to brson/rustup.rs that referenced this issue Nov 22, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
brson added a commit to brson/rustup.rs that referenced this issue Nov 22, 2016
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
@japaric
Copy link
Member Author

japaric commented Dec 3, 2016

@brson Could we get a new rustup release that contains this fix? A few rustc devs have hit this bug while testing their rustc changes. (Some of us use rustup toolchain link to test dev rustcs with Cargo)

nodakai pushed a commit to nodakai/rustup.rs that referenced this issue Apr 23, 2017
…ctly

The way the proxy was setting up the PATH variable contained two bugs:
first, that it allowed the toolchain path to precede the value of CARGO_HOME/bin;
but second that it didn't add CARGO_HOME/bin to the path at all. The result
was that when e.g. cargo execs rustc, it was directly execing the toolchain
rustc.

Now it execs the proxy, assuming that CARGO_HOME/bin is set up correctly,
and guaranteeing not to run the toolchain tool directly.

Fixes rust-lang#809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants