How to uninstall Rust that was installed via rustup? - rust

I installed Rust on my Ubuntu 16.04 machine through
curl https://sh.rustup.rs -sSf | sh
as can be seen on the Installation Page.
How do I now uninstall Rust?

To uninstall rustc, rustup and cargo from my Ubuntu 16.04 installation, I did:
rustup self uninstall
and it worked.

If you pay attention to the message you get while installing, you will find the command you are looking for:

As for Linux based operating systems, the following command can be used:
rustup self uninstall
this will remove all the Rust Compiler, Tool Chains and Data including rustc and cargo
If you're one window this should wok, but you have to remove C++ build tools manually if you want to remove it as well, though I would never recommend.

You can do this without manually deleting the old rust binaries by uninstalling cargo and then auto-removing its now un-needed dependencies:
sudo apt remove cargo
sudo apt autoremove

Related

Enable additional targets with system-provided rust packages, not rustup

I wanted to put together a Rust toolchain using the system package manager rather than downloading the rustup installer, and cross-compile for a Raspberry Pi 3
To that end, in Ubuntu 20.04 I have installed rustc and gcc-arm-linux-gnueabihf.
However, the cargo build --bins --release --target armv7-unknown-linux-gnueabihf command fails with
error[E0463]: can't find crate for `core`
|
= note: the `armv7-unknown-linux-gnueabihf` target may not be installed
Is there a way to get this working, other than curl https://sh.rustup.rs -sSf | sh && rustup target add arm-unknown-linux-gnueabihf?
Chances are that you are better off using a docker image to help.
I found this in general:
https://kerkour.com/rust-reproducible-cross-compilation-with-docker/
and, for armv7 I'd say something akin to:
apt update && apt upgrade -y
apt install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross
rustup target add armv7-unknown-linux-gnueabihf
rustup toolchain install stable-armv7-unknown-linux-gnueabihf
under Ubuntu should do the trick.

Is there a way to update visual-studio-code-bin which is installed from the arch wiki

visual-studio-code-bin is installed from the arch wiki. The only way I know how to actually update the software is reinstalling it again from the arch wiki which is tedious and inconvenient.
Any help is appreciated
Old post with a lot of split information so for anyone who finds this later, you have 2 choices:
Install the open source version of visual studio code from the official repos.
Install the official Microsoft binary version via the AUR that contains some proprietary code from Microsoft that is not available in the fully open version (e.g. some debugging some languages).
Info on how to do this can be found in the wiki.
It depends on how you installed vscode. If you did sudo pacman -S code, then the solution is to run it again. But if you did yay -S visual-studio-code-bin, then you should run THIS command again.
The best way to use VS Code on Arch is to use the open source version on the community repos. Which you can install by doing
sudo pacman -S code
visual-studio-code-bin is the proprietary binary which can be installed from the Arch User Repository.
If for some reason you want to go for the latter approach, you can either use an AUR helper or manage everything manually.
You can see the Arch Wiki's page on AUR helpers which shows the different options you have: https://wiki.archlinux.org/index.php/AUR_helpers
You can use these helpers to help manage your updates just like you would on pacman.
Here's how you would do things manually: https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_and_upgrading_packages
Just as a warning, AUR helpers are not supported by Arch Linux and the manual approach, though less user friendly is the recommended way by the Arch Wiki to manage your AUR Packages.
First a short version:
Simply run
sudo pacman -Sy
sudo pacman -S visual-studio-code-bin
The longer explanation:
Getting the right version of vscode
First of all, "code" and "visual-studio-code-bin" are two different packages. "code" is an open-source release and "visual-studio-code-bin" is an Microsoft-branded release. One of the major differences is that "code" doesn't support any Microsoft Extensions like C/C++, to my knowledge. This information can be found in the arch wiki: https://wiki.archlinux.org/title/Visual_Studio_Code#Installation. For more detailed information about the differences I'll refer you to the vscode repository: https://github.com/microsoft/vscode/wiki/Differences-between-the-repository-and-Visual-Studio-Code
By running "sudo pacman -S code" you (unintentionally) uninstall "visual-studio-code-bin" and install "code" because of wired some decency conflict.
So if you want to update/install "visual-studio-code-bin" run:
sudo pacman -S visual-studio-code-bin
This should fix any Problems with no functioning Microsoft-Extensions
Of course if you want to sick to the open-source version you can use
sudo pacman -S code
Fixing your Problem with not updating to the right version
I have to admit this took me ages. I had two machines, one with an freshly installed version of geruda Linux (an arch based distro) and an six moth old version of geruda Linux. Both had vscode installed. At the time of writing this the current version of vscode is 1.59.0-1. Interestingly the my old machine, witch had vscode version 1.58.0-1 installed didn't know that there was an newer version. The newer machine was aware of the the newer version. An simply running pacman -S visual-studio-code-bin didn't change anything. This hinted my to the problem of an not synchronized package database. And forcefully synchronizing the database with
sudo pacman -Sy
did the trick for me. For a more detialed information I would redirect you to the man pages: https://archlinux.org/pacman/pacman.8.html or this thread https://bbs.archlinux.org/viewtopic.php?id=117765. After running this command you only need to install vscode with "sudo pacman -S visual-studio-code-bin" or "sudo pacman -S code" to get the newest version of vscode
As rightly said by #AlexanderHD27 code is open source and vscode is microsoft official version but it is not open source. though code is more like an experimental version of of vscode; however, you can install code directly in archlinux using sudo pacman -S code but for the the vscode you have to clone the repository from github and install in the following way:
git clone visual-studio-code-bin
then cd visual-studio-code-bin and makepkg -si
remember if you don't have git installed you can do that using sudo pacman -S git. As for the update; code is updated during system full update but vscode is not updated. So, you have to cd into the directory again and do git pull the makepkg -si again.
As KamilCuk and Aviad mentioned there is no visual-studio-bin package, since it is a aur package you can use yay (AUR helper) to get a updateable version. For more information about yay see: https://github.com/Jguer/yay.
Install yay
sudo pacman -S --needed base-devel git
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd ..
rm -rf yay
Install visual-studio-code-bin with yay
# install
yay -S visual-studio-code-bin
If you installed vscode via pamac manager in manjaro, try this:
pamac update
To update with the cloned AUR directory.
First update pacman database:
pacman-Sy
Then in the AUR directory you can update the AUR to the latest version with:
git pull
Then update dependencies with:
makepkg -s
Finally you install it:
makepkg -i
==> WARNING: A package has already been built, installing existing package...
==> Installing package visual-studio-code-bin with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...
Packages (1) visual-studio-code-bin-1.73.1-1
Total Installed Size: 324.26 MiB
Net Upgrade Size: 29.66 MiB
:: Proceed with installation? [Y/n]

Is there a way to update a binary package? [duplicate]

I'd like to update a package that I used cargo install to globally install packages, such as rustfmt or racer. I can't find a way to update an installed package without first deleting it (via cargo uninstall) and then running the install command again. Is there an update command?
There is no such command in vanilla cargo (well, there's cargo install but that's for dependencies), but since cargo supports third-party subcommands there is an answer: the cargo-update crate.
Install as usual with
cargo install cargo-update
then use
cargo install-update -a
to update all installed packages, for more usage information and examples see the cargo install-update manpage.
Disclaimer: am author
As of Rust 1.41.0, you can use the following command to update crates to their latest version:
cargo install <crate>
This came from pull request #6798 (Add install-upgrade) and was stabilized in #7560 (Stabilize install-upgrade).
How does it work?
Instead of failing when cargo install detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date".
Forcing an upgrade / re-installation
The following command will always uninstall, download and compile the latest version of the crate - even if there's no newer version available. Under normal circumstances the install-upgrade feature should be preferred as it does save time and bandwidth if there's no new version of the crate.
cargo install --force <crate>
Documentation
Further information can be found in the GitHub issue rust-lang/cargo#6797 and in the official documentation chapter.
A solution I've found is to add the --force flag to the install command. For example cargo install --force clippy. This will effectively re-install the latest version.
Here is a one-liner to update all installed Cargo crates, except those installed from a local folder:
cargo install $(cargo install --list | egrep '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')
Explanation:
List installed packages
Filter to lines which contain package names and versions, and exclude ones with filesystem paths
Cut those lines to only include the package name
cargo install with the resulting package names

No default toolchain configured after installing rustup

I installed Rust using rustup, but when I try to enter a Rust command like cargo or rustc in my console, the following error appears:
error: no default toolchain configured
Is this a known issue?
If it seems that rustup did not successfully install and configure the stable toolchain, you can do it manually:
rustup install stable
rustup default stable
After testing, it seems like my incomplete installation may have been caused by a network error. You can also try to reinstall to solve the problem.
The problem is due to my connection and my proxy which didn't allow rustc, cargo, and others to be downloaded.
I thought that the all the executables were all-in-one but apparently not.
In my case, I had multirust installed and the following worked for me:
multirust install stable
multirust default stable
I installed rust with root, but my IDE doesn't run as root, so I installed rust without root, all worked well.

Does cargo install have an equivalent update command?

I'd like to update a package that I used cargo install to globally install packages, such as rustfmt or racer. I can't find a way to update an installed package without first deleting it (via cargo uninstall) and then running the install command again. Is there an update command?
There is no such command in vanilla cargo (well, there's cargo install but that's for dependencies), but since cargo supports third-party subcommands there is an answer: the cargo-update crate.
Install as usual with
cargo install cargo-update
then use
cargo install-update -a
to update all installed packages, for more usage information and examples see the cargo install-update manpage.
Disclaimer: am author
As of Rust 1.41.0, you can use the following command to update crates to their latest version:
cargo install <crate>
This came from pull request #6798 (Add install-upgrade) and was stabilized in #7560 (Stabilize install-upgrade).
How does it work?
Instead of failing when cargo install detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date".
Forcing an upgrade / re-installation
The following command will always uninstall, download and compile the latest version of the crate - even if there's no newer version available. Under normal circumstances the install-upgrade feature should be preferred as it does save time and bandwidth if there's no new version of the crate.
cargo install --force <crate>
Documentation
Further information can be found in the GitHub issue rust-lang/cargo#6797 and in the official documentation chapter.
A solution I've found is to add the --force flag to the install command. For example cargo install --force clippy. This will effectively re-install the latest version.
Here is a one-liner to update all installed Cargo crates, except those installed from a local folder:
cargo install $(cargo install --list | egrep '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')
Explanation:
List installed packages
Filter to lines which contain package names and versions, and exclude ones with filesystem paths
Cut those lines to only include the package name
cargo install with the resulting package names

Resources