What is the correct way to keep `rustup` up-to-date?

As noted in: Rustup package does not provide rustup - #4 by decathorpe

Installing the rustup package does not actually provide the rustup binary. It provides rustup-init which can be run to do the initial installation of rustup.

I was recently bit by this, because even though I’ve had rustup installed for quite some time, I failed to realize it was extremely outdated (over 2 years outdated!). Updating the rustup package doesn’t update the rustup binary, just as it doesn’t install it.

Normally, rustup is capable of self-updating. But using the rustup installed by rustup-init provided by the rustup package to run rustup self update just leads to:

error: self-update is disabled for this build of rustup
error: you should probably use your system package manager to update rustup

It seems like a workaround is to run rustup-init again, but this feels janky and wrong, and also messes with my .bashrc when it doesn’t need to. Given that having the rustup package only provide rustup-init instead of rustup was an intentional decision, what is the intended way for us to actually update rustup? It seems strange that updating the package doesn’t do it, yet the package still disables self-updates.

If anyone knows where I could find more about the reasoning for the decision to have the rustup package provide rustup-init, I’d be interested in reading up on that, too.

Hi Jason,

From what I understand, the Fedora package only provides rustup-init, which has self-updates disabled. Running it installs another copy in ~/.cargo/bin/, and that copy isn’t managed by DNF.

So updating the package doesn’t update the rustup you actually use. The workaround is to run:

sudo dnf upgrade rustup
rustup-init -y --no-modify-path --default-toolchain none

You can compare the versions too:

rustup-init --version
rustup --version

Another option is to use the installer from https://rustup.rs, but then DNF won’t manage rustup anymore.

Not sure about the exact reason behind Fedora’s packaging choice. The Fedora package spec and changelog might be worth checking.

I think the package description could explain this better, since updating the RPM doesn’t update the rustup binary in your home directory. Maybe a Bugzilla request would be worth it.

Hello, rustup package maintainer here.

The primary motivation for providing rustup as a package in Fedora is so that you don’t have to curl | bash (which is generally considered … erm … “questionable” from a security perspective).

The way rustup and its self-update functionality work are kind of incompatible with providing a fully functional “rustup” setup just by installing it:

  1. We can’t provide the usual symlinks that rustup would set up for your toolchain (i.e. rustc, cargo, clippy, rustfmt, etc.) in the system-wide $PATH because those would conflict with the system packages for those same tools.
  2. The self-update functionality would (I think?) overwrite the system-provided rustup multicall binaries with ones downloaded from rustup.rs - but not doing that is the entire reason why people would install rustup from the package repos.

So I think running ↑ after a rustup package update really is the only easy way to keep your rustup install up-to-date.

Since packages aren’t allowed to modify users’ $HOME directories, I think this might also be the only way this can work. But if anybody has an idea for how to improve this from a packaging perspective, I’m open to suggestions.

Thanks for your response. There’s something I don’t really understand though, forgive my ignorance.

What do you mean by “system-provided rustup multicall binaries”? Are you referring to rustup? If so, I think you might be wrong? Updating using rustup-init would do the same thing, wouldn’t it? At least, that seems to be what is implied here:

RUSTUP_VERSION (default: none). Overrides the rustup version (e.g. 1.27.1) to be downloaded when executing rustup-init.sh or rustup self update.

So in order to not do that, you’d need to commit to never updating rustup. Which you can achieve by just doing rustup set auto-self-update disable. Which would still allow those who want to receive updates to rustup to take advantage of the self-update functionality.

The reason I install rustup from the package repos is because I use an atomic version of Fedora, so I generally prefer using Fedora packages since they should usually account for any weirdness that comes with that. I feel more confident that Fedora packages will just work on my system by the time they make it to stable.

Thanks again for your response and for your work packaging this. If I’m misunderstanding something, I’m happy to be corrected.

Running rustup-init creates symlinks in (modified) $PATH as rustc, cargo, etc. that point at itself. If you look at the contents of ~/.cargo/bin/ you can see that `cargo, rustc, rustfmt, etc. are all symbolic links that point at rustup. The executable behaves differently (e.g. it behaves as if it were cargo if it is called as “cargo”, but it behaves as if it were rustc if it is called as rustc, etc. - that’s what “multicall” refers to).

So I assume that the self-update functionality (that is disabled in Fedora package builds) would overwrite rustup with rustup downloaded from rust-lang.org, making the executable from the Fedora package unused, and have all those symlinks just point at the freshly downloaded rustup executable.

This seems to only apply to the shell script wrapper around rustup-init, (i.e. rustup-init.sh), not rustup-init itself. This wrapper is only used as an architecture-independent way to download the actual rustup-init for the current architecture, and it’s not even shipped in the Fedora package for rustup, so I don’t think it’s relevant here.

Ah, I think that was my misunderstanding. I didn’t realize rustup-init and rustup-init.sh were different. Thanks!

Just so you know, it seems this discussion has spawned an issue for improving support for packaging: Better setup experience for third-party packagers? · Issue #5149 · rust-lang/rustup · GitHub

It looks like it might be a good idea to reach out to the maintainer if you get a chance:

I wonder whether this is a good opportunity to get in touch with the packagers to see how they think the flow should be on their side… however I might have difficulties in getting the contacts I need :eyes:

They might be able to have rustup-init do a symlink instead of a copy, which I think would make it so updating the rustup package would update rustup without needing to re-run rustup-init.