Cannot install rustup alongside rust

XXXX@XXXX:/usr/bin$ sudo curl https://sh.rustup.rs -sSf | sh
info: downloading installer
error: it looks like you have an existing installation of Rust at:
error: /usr/bin
error: rustup cannot be installed alongside Rust. Please uninstall first
error: if this is what you want, restart the installation with `-y'
error: cannot install while Rust is installed

This is the error I get when I try to install rustup. My current version of rust is out of date and I cannot find a way to update it.
How can I get rid of it so I can install rustup or update it

Hi

You need to uninstall rust first and then install rustup

What OS are you on? It looks like you have a system rust compiler installed. On an apt based system like Debian or Ubuntu you might uninstall it with sudo apt-get remove rustc.

One other note: You don't need too install Rust as root. It's more common install it as your user.

1 Like

Additionally, that isn't even what that command actually does, it just runs curl as root, which is meaningless on its own.

1 Like

Hi any idea why this is? I prefer to install from apt if I can. Is this a bug that might be fixed in the future by rustup or ubuntu?

Whatever is installed by apt is under the control of Ubuntu. Rustup has nothing to do with it.

It's not a bug. You have to pick a package manager, either rustup or apt. You can't mix them, since if rustup would change files installed by apt, apt would freak out and break (I've had that situation once when I manually updated files from an installed package. apt would just tell me that everything is broken and give up).

is it not possible to install files in different locations, similar to java & python & node?
e.g. set a X_HOME variable, or variables, and install everything relative to that.

Generally if you use rustup you can have as many versions of rust installed as you want, and they are installed in ~/.cargo/. You can choose which version you want by adding e.g. +nightly as the first parameter to the command, and rustup can be used to change the default both globally and on project by project basis.

Unlike python and node, you don't install dependencies globally: cargo automatically puts them in the target directory in the project folder. This removes the need to have separate installations like you need for python and node.

When using apt to install rust you are forced to use a specific version of stable rust, although it still splits up dependencies using target, so that's fine if you're good with that version of the compiler.