Deleted ~/.cargo accidentally and now can't uninstall or reinstall rust

Hello, I've accidentally deleted ~/.cargo and now I can't uninstall or reinstall rust
when I run :
rustup self uninstall
I get the following message:
bash: rustup: command not found

when I try to reinstall rust using the standard official way:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

I get the following message:

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

it also appears that I still have ~/.rustup and the remaining rust files like rustc, rustfmt..etc in /usr/bin/

how do I reinstall rust or at worst case scenario, remove it entirely from my system?

Everything constituting a rust install should be contained in .rustup and .cargo, so just remove .rustup and you should be good.

Unrelated to that, it says it looks like you have an existing installation of Rust at: /usr/bin which means you also installed rust using your package manager. The general advice is to uninstall that one (apt remove rust or similar) and use rustup to install it instead.

7 Likes

Hello, thank you for your reply. I deleted .rustup and uninstalled the other rust version using pacman and now when I run the default installer it doesn't complain anymore

I haven't reinstalled rust yet however, every time I open the terminal I get the following message automatically:
bash: /home/user/.cargo/env: No such file or directory

after some searching in dotfiles I found some sort of rust environment variable in .profile, .bash_profile and .bashrc

Do I need to delete these entries manually before I reinstall or should I just reinstall and not worry about them?

1 Like

Don't worry about them. They are quiescent, precisely because ~/.cargo/env doesn't exist.

After reinstallation they would start working again.

1 Like

It worked well without any problems, thanks!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.