41

cargo: no such subcommand: +nightly

 3 years ago
source link: https://ma.ttias.be/cargo-no-such-subcommand-nightly/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

cargo: no such subcommand: +nightly

Mattias Geniar, November 23, 2020

Follow me on Twitter as @mattiasgeniar

I was trying to run the following command:

$ cargo +nightly install [package]
error: no such subcommand: `+nightly`

But … that didn’t work. This was my fix:

Remove Rust/Cargo from default package manager

I first removed the cargo package I had installed via apt from my system:

$ apt remove rustc rust-gdb libstd-rust-dev libstd-rust-1.43

This was on a rather old Ubuntu 18.04 LTS, so it had an outdated version of Rust/Cargo. To see which Rust packages you have installed, try this:

$ dpkg -l | grep -i rust

And see what packages come up with the name “rust” in them.

Install latest cargo release

From the official docs:

$ curl https://sh.rustup.rs -sSf | sh

Almost there!

Install package dependencies

But it still didn’t work straight away:

$ cargo +nightly install [package]
error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed

Almost there! First, install the nightly toolchain using rustup (which is now installed, thanks to the installer we ran above):

$ rustup toolchain install nightly
[...]
nightly-x86_64-unknown-linux-gnu installed - rustc 1.50.0-nightly (a0d664bae 2020-11-22)

Now, the +nightly package install works:

$ cargo +nightly install [package]
[...]
   Compiling rustc-hex v2.1.0
   Compiling fake_instant v0.4.0
   Compiling ansi_term v0.11.0
   Compiling gimli v0.23.0
   Compiling urlencoding v1.1.1
   ...
    Building [=============>       ] 107/411: ipnet, humantime, parity-wasm, object

(Note: I had to install pkg-config first before the cargo install could compile the package.)


Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK