cargo +nightly error : no such subcommand
Asked Answered
D

2

8

While executing : cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force in Ubuntu 18.04, is throwing

error: no such subcommand: +nightly

My system has following nightly version

rustc 1.47.0-nightly

 cargo 1.47.0-nightly install --git https://github.com/alexcrichton/wasm-gc --force

Even, above command throws similar error!

Cmd1 : rustup toolchain install nightly

Cmd2 : rustup update

Even after running these commands as suggested over communities, error isn't resolved. I'm new to rust & couldn't link cargo to installed nightly via rustup.

System Details

cargo version : 1.43.0

rustup version : 1.22.1 (b01adbbc3 2020-07-08)

Cmd 3:

which cargo  : /usr/bin/cargo
Damiandamiani answered 25/8, 2020 at 8:24 Comment(2)
Can you post the output of which cargo? This looks like you might have either Cargo from your package manager, or a manually installed Cargo taking precedence over the rustup cargo alias.Bobker
I concur with @justinas, the cargo version as of right now is 1.45.1 not 1.43.0. Given you're using ubuntu and it does bundle cargo but not rustup this is likely a path conflict, rustup is installing cargo (and the rest) in one location, but you're using the distro's cargo from another. In which case you should remove the distro-provided cargo, or at least fix your PATH such that the rustup-installed one takes precedence.Giverin
B
13

which cargo printing out /usr/bin/cargo indicates that it defaults to Cargo that you installed from your OS's package manager (apt).

Invocations with the toolchain version like cargo +nightly are not a feature of Cargo, but rather Rustup. In fact, Rustup's cargo is a link to rustup that then invokes the "real" cargo stored under .rustup/toolchains.

The easiest way to solve this would be to uninstall the Cargo you obtained from Ubuntu repositories:

$ apt remove cargo

Otherwise, you could try to manipulate your PATH such that /home/<your_username>/.cargo/bin comes before /usr/bin.

If you do not have rustup installed yet, you need to install it.

$ brew install rustup-init # OSX
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh  # Ubuntu/Debian

Then configure rustup, you can set the config to default to start

$ rustup-init

Finally you can install specific version of rust, for instance nightly

$ rustup toolchain install nightly
Bobker answered 25/8, 2020 at 9:36 Comment(0)
C
0

I was on a mac and not using apt so for me I just had to reference the full path for cargo and it worked.

$HOME/.cargo/bin/cargo +nightly --git https://github.com/alexcrichton/wasm-gc

Hope that helps somone

Consuela answered 18/1, 2022 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.