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
I wonder why can't rustup have a special system toolchan, that cannot be installed or updated but can be chosen.
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.
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.
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.
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.
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
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.
@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
Just run:
sudo apt remove rustc
then
curl https://sh.rustup.rs/ -sSf | sh
@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?
The copy of
rustcthat 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?
I don't know. Probably one of the admins removed it.
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
.
@anjalianjali1234 was that comment directed at me? I'm not sure what you're getting at.
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.
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?
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!
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
@ssowellsvt - Spot on - Thanks!
Yes, use
export RUSTUP_INIT_SKIP_PATH_CHECK=yes
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
Just run:
sudo apt remove rustc
then
curl https://sh.rustup.rs/ -sSf | sh
This worked for me
Most helpful comment
Just run:
sudo apt remove rustcthen
curl https://sh.rustup.rs/ -sSf | sh