Skip to content

when rustup finds an existing rust install it doesn't give the user any hints about what to do next #3679

Open
@davidbuzz

Description

@davidbuzz

Problem you are trying to solve

have an app that I'm building that gives instructions to "install rust", and links to the rustup site.
I ran this as instructed:

curl https://sh.rustup.rs -sSf | sh
info: downloading installer
warning: it looks like you have an existing installation of Rust at:
warning: /usr/bin
warning: It is recommended that rustup be the primary Rust installation.
warning: Otherwise you may have confusion unless you are careful with your PATH
warning: If you are sure that you want both rustup and your already installed Rust
warning: then please reply `y' or `yes' or set RUSTUP_INIT_SKIP_PATH_CHECK to yes
warning: or pass `-y' to ignore all ignorable checks.
error: cannot install while Rust is installed

rustup's idea of what rust is, not installed, because of "some other" rust and no idea how to fix that above error.

Solution you'd like

I wanted it to install rust using rustup

after 10 minutes of googling this came up:
https://www.reddit.com/r/rust/comments/se7ecj/how_to_uninstall_rust_without_rustup/
rust-lang/rls#1399
#953

.. so its not just me..

solution:
emit this message instead:
"Would you like to uninstall the system-provided/older rust and use a newer one?" run 'sudo apt remove rustc' or similar for your platform

Notes

No response

Activity

rami3l

rami3l commented on Feb 22, 2024

@rami3l
Member

@davidbuzz Thanks a lot for filing this issue!

No, it's not necessary for you to remove the system-provided Rust. Looking at the user guide you can see that it's possible for those Rust installations to coexist (and for Rustup to adopt the system toolchain), but the PATH must be modified in such a way that Rustup's cargo shim precedes the original cargo, etc.

That's exactly the meaning of the phrase

It is recommended that rustup be the primary Rust installation. Otherwise you may have confusion unless you are careful with your PATH.

I would be happy to accept potential wording improvements based on this point :)

davidbuzz

davidbuzz commented on Feb 22, 2024

@davidbuzz
Author

'You appear to have a rust installed with your package-manager. Usually there's no need for two versions of rust, but the one we're about to install is almost certainly newer.. More details about co-existing in the user-guide at https://rust-lang.github.io/rustup/installation/already-installed-rust.html
Would you like us to first remove the older one first? Y/n"
[If they say 'n', maybe point out the directories of both, and which one is first-in-their-path right now]

davidbuzz

davidbuzz commented on Feb 22, 2024

@davidbuzz
Author

.. and why does it matter? ... because 'rustup' binary is not provided in the older/bundled build.

rami3l

rami3l commented on Feb 22, 2024

@rami3l
Member

.. and why does it matter? ... because 'rustup' binary is not provided in the older/bundled build.

Thanks! I get your point. However, apart from having installed rust from the system package manager, this error can also occur when you run rustup-init and you already have an existing Rustup installation, whether via the system package manager or via a manual installation. From Rustup's point of view we should give general directions instead of directly helping the user out, but indeed it would be nice if we can point out several common possibilities.

added this to the 1.28.0 milestone on Feb 22, 2024
modified the milestones: 1.28.0, 1.28.1 on Aug 9, 2024
lgimberis

lgimberis commented on Nov 21, 2024

@lgimberis

Still a problem. Personally, I just had to apt remove rustc.

The function that must be true for this error to be printed is named rustc_or_cargo_exists_in_path. A message that explicitly reflects this (that rustc and/or cargo being on PATH is causing the problem) would be more actionable and helpful than hearing "because rust is installed", as rust is not a program and cannot be uninstalled.

modified the milestones: 1.28.2, 1.28.3 on Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @davidbuzz@rami3l@lgimberis

        Issue actions

          when rustup finds an existing rust install it doesn't give the user any hints about what to do next · Issue #3679 · rust-lang/rustup