I understand that rustup installs the rustc and cargo binaries to ~/.cargo/bin, but where does it install the rustup executable to? As far as I can tell this isn't explained in any documentation and running the installer doesn't tell you either. I'd like to avoid it being installed to anywhere except my home directory, if possible. I'm using macOS if that makes a difference.
By default, rustup is also installed to your home directory:
$ which rustup
/Users/shep/.cargo/bin/rustup
The documentation states:
rustup installs rustc, cargo, rustup and other standard tools to Cargo's bin directory. On Unix it is located at $HOME/.cargo/bin and on Windows at %USERPROFILE%\.cargo\bin. This is the same directory that cargo install will install Rust programs and Cargo plugins.
It goes on to describe how to change the defaults:
rustup allows you to customise your installation by setting the environment variables CARGO_HOME and RUSTUP_HOME before running the rustup-init executable. As mentioned in the Environment Variables section, RUSTUP_HOME sets the root rustup folder, which is used for storing installed toolchains and configuration options. CARGO_HOME contains cache files used by cargo.
In my case rustup (along with it's installed toolchains) is in a folder named .rustup which is on the same level as .cargo
If you used Chocolatey to install Rust, it installs to C:\ProgramData\chocolatey\bin (at least when I used it).
To verify it was installed by Chocolatey, in a PowerShell window run choco list --local-only and see if the returned list contains Rust.
You can uninstall Chocolatey's Rust instance by running choco uninstall rust in an admin PowerShell window.
Related
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
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
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.
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
I have installed Haskell Platform 2012 in Windows 7. I write in the console cabal update and I take a message that there is a new version of cabal. I write cabal install cabal-install . After installation finishes it tells me that the cabal has been installed in C:\username\AppData\Roaming\cabal. So when I do cabal update again I am taking the same message that I have to install the new version of cabal. I have tried to change the cabal directory from the config file but cabal ignores the config file. Is Haskell working only on Unix? Thanks
The problem is that the cabal executable that came with Haskell Platform gets picked up instead of the one that you installed.
You need to edit the value of the PATH environment variable and place %AppData%\cabal\bin before %PROGRAMFILES%\Haskell Platform\...\bin so that it's given higher priority.
You need to add C:\username\AppData\Roaming\cabal (or whatever directory now has the cabal executable -- use e.g. dir or your favorite file manager to verify that you have the right place) to your %PATH% environment variable and restart your command prompt.
The error message is incomplete. Install cabal-install globally as:
cabal install cabal-install --global