rustup: Can't install rustup because of existing rust that I can't remove

We have a copy of rustc version 1.14.0 installed on my school’s server. I want to set up the latest version of rust (currently 1.15.1) in my home directory, ideally using rustup. But because of the existing copy of rust - which I can’t remove, since I don’t have root access - rustup-init fails with the following error:

warning: it looks like you have an existing installation of Rust
warning: rustup cannot be installed alongside Rust. Please uninstall first
warning: run `/usr/local/lib/rustlib/uninstall.sh` as root to uninstall Rust
error: cannot install while Rust is installed

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 27 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Just run:

sudo apt remove rustc then curl https://sh.rustup.rs/ -sSf | sh

You can bypass the check by setting RUSTUP_INIT_SKIP_PATH_CHECK to yes:

$ ./rustup-init 
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
$ RUSTUP_INIT_SKIP_PATH_CHECK=yes ./rustup-init 

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.
# ...

I think the error message should at least mention this environment variable – I only found it after looking through the source of rustup-init.

Sorry for the late reply.

You just need to run: curl -sSf https://static.rust-lang.org/rustup.sh | sh

it will fix the problem.

After compiling all above comments, I used following command and it worked perfectly with previously installed rust. curl https://sh.rustup.rs -sSf | RUSTUP_INIT_SKIP_PATH_CHECK=yes sh

Yes, use

export RUSTUP_INIT_SKIP_PATH_CHECK=yes
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env

I wonder why can’t rustup have a special system toolchan, that cannot be installed or updated but can be chosen.

@ssowellsvt - Spot on - Thanks!

Anyway, it looks like the issue was fixed in https://github.com/rust-lang/rustup.rs/pull/705. You can now add the -y option to skip the check for an existing rustc or cargo binary in PATH, and this is referenced in the error message.

https://doc.rust-lang.org/1.0.0/book/installing-rust.html

Please follow this link.

On Thu, Jan 17, 2019 at 4:25 AM Michael Hewson notifications@github.com wrote:

I don’t know. Probably one of the admins removed it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rust-lang/rustup.rs/issues/953#issuecomment-454975864, or mute the thread https://github.com/notifications/unsubscribe-auth/AgKDbJJMUwF5vmUhzS8ynn6RbEw0HmmZks5vD63xgaJpZM4L-YjL .