cargo: no such subcommand: +nightly

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

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.