Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mikeyhew opened this issue Feb 12, 2017 · 27 comments
Closed

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

mikeyhew opened this issue Feb 12, 2017 · 27 comments
Labels

Comments

@mikeyhew
Copy link

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
@suhr
Copy link

suhr commented Mar 3, 2017

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

@brson brson added the bug label Mar 16, 2017
@brson
Copy link
Contributor

brson commented Mar 17, 2017

I'm not sure the best way to fix this offhand. I think the reason I did this was to reduce potential confusion after install, having seen cases where people were still invoking the old rustc afterwards. For example, there are many cases where rustup fails to configure PATH, and that would leave the old rustc active.

We could possibly loosen this to a warning, like "warning: There is an existing rustc installed to $path. Depending on how $PATH is configured, the existing toolchain may take precedence."

Could also make it interactive, but that's deeper surgery.

A 'system' toolchain is a useful feature to add, but does not solve the problem of users being confused about which toolchain they are using.

@chris3k
Copy link

chris3k commented May 5, 2017

Temporary workaroud (let's call it - force install) for this, is to download rustup.rs source code and comment sanity checks in do_pre_install_sanity_checks() (or apply patch)

diff --git a/src/rustup-cli/self_update.rs b/src/rustup-cli/self_update.rs
index 7d1a641..c289962 100644
--- a/src/rustup-cli/self_update.rs
+++ b/src/rustup-cli/self_update.rs
@@ -381,7 +381,7 @@ fn do_pre_install_sanity_checks() -> Result<()> {
         warn!("it looks like you have an existing installation of Rust");
         warn!("rustup cannot be installed alongside Rust. Please uninstall first");
         warn!("run `{}` as root to uninstall Rust", uninstaller_path.display());
-        return Err("cannot install while Rust is installed".into());
+        // return Err("cannot install while Rust is installed".into());
     }

     if rustup_sh_exists {

Then compile (cargo build) and then proceed with installation, e.g. RUSTUP_HOME=/home/user/.multirust CARGO_HOME=/home/user/.cargo ./target/debug/rustup-init --no-modify-path.

@mikeyhew
Copy link
Author

The copy of rustc that we had on my school's server has since been removed, so I was able to install rustup just fine when I tried it last week. That being said, there should be some way to force installation, even if there is an existing Rust installation somewhere.

@mgeisler
Copy link
Contributor

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.

@yangchengjian
Copy link

I meet the some question too, and I use

$RUSTUP_INIT_SKIP_PATH_CHECK=yes sh ./rustup-init.sh 

to reinstall rust, It's work.

Thanks @mgeisler

@anjalianjali1234
Copy link

anjalianjali1234 commented Aug 28, 2018

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.

@geofmureithi-zz
Copy link

geofmureithi-zz commented Dec 28, 2018

@anjalianjali1234 This no longer works:(rustc1.3.0)

$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
The location of rustup.sh has moved.
Run the following command to install from the new location:
    curl https://sh.rustup.rs -sSf | sh

@ssowellsvt
Copy link

Just run:

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

@mikeyhew
Copy link
Author

mikeyhew commented Jan 12, 2019

@ssowellsvt one of the premises of this issue is that the user doesn't have root access and can't use sudo.

But as @mgeisler pointed out, RUSTUP_INIT_SKIP_PATH_CHECK=yes works. So I think we can close this issue?

@PAVAN-IS201401018
Copy link

The copy of rustc that we had on my school's server has since been removed, so I was able to install rustup just fine when I tried it last week. That being said, there should be some way to force installation, even if there is an existing Rust installation somewhere.

How it was removed?

@mikeyhew
Copy link
Author

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

@anjalianjali1234
Copy link

anjalianjali1234 commented Jan 17, 2019 via email

@mikeyhew
Copy link
Author

@anjalianjali1234 was that comment directed at me? I'm not sure what you're getting at.

@mikeyhew
Copy link
Author

Anyway, it looks like the issue was fixed in #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.

@Li-ReDBox
Copy link

Not sure what has happened, using -y or RUSTUP_INIT_SKIP_PATH_CHECK to stop checking when installing rustup did not work for me:

./rustup-init --version
rustup-init 1.16.0 (beab5ac2b 2018-12-06)

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

./rustup-init -y./rustup-init -y
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

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

Is it possible to install rustup without un-installing?

@xtowerlink
Copy link

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 @.***> 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 <#953 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AgKDbJJMUwF5vmUhzS8ynn6RbEw0HmmZks5vD63xgaJpZM4L-YjL .

tks!

@xtowerlink
Copy link

thank you very much !

@HarpreetSandhu
Copy link

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

@jblancaster
Copy link

@ssowellsvt - Spot on - Thanks!

@tpmccallum
Copy link

Yes, use

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

BeniCheni pushed a commit to BeniCheni/rustup.rs that referenced this issue May 10, 2020
@kelvinkirima014
Copy link

Just run:

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

This worked for me

@mrcnski
Copy link

mrcnski commented Dec 2, 2021

On OSX, I had to manually go into /usr/local/bin and uninstall all the rust* binaries and the cargo binary. For some reason rustup self uninstall was not removing these.

@kinnison
Copy link
Contributor

kinnison commented Dec 3, 2021

@m-cat rustup-init would never have installed binaries into /usr/local/bin unless you did something very odd, so that's expected.

@pdunne
Copy link

pdunne commented Dec 29, 2021

On OSX, I had to manually go into /usr/local/bin and uninstall all the rust* binaries and the cargo binary. For some reason rustup self uninstall was not removing these.

Same thing happened to me (OSX Big Sur, Intel Mac) after updating to either 1.56 or 1.57. Somehow I had the binaries also in /usr/local/bin and this messed up cross-compilation, i.e. not recognising installed targets like wasm32-unknown-unknown.

after running rustup self uninstall I removed the rust* and cargo bin from /usr/local/bin, and was then able to reinstall Rust. This also solved my cross-compilation problems.

@CMCDragonkai
Copy link

If an existing rust installation is left there, is there a way to force rustup-init to always setup the PATH so that its installed version takes precedence?

@rbtcollins
Copy link
Contributor

@CMCDragonkai we attempt to do that when you accept the warning, but its not always possible depending on how you have your shell configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests