Rustup: Failed to uninstall on macOS 10.13.2

Created on 20 Jan 2018  路  16Comments  路  Source: rust-lang/rustup

Uninstalling Rust via rustup failed with following message, even there still be the directory exists.

error: could not remove 'cargo_home' directory: '/Users/user/.cargo'
info: caused by: No such file or directory (os error 2)

Environment is

  • macOS 10.13.2
  • Bash

The following is what I did and step to reproduce.

MacBook-Pro:~ user$  curl https://sh.rustup.rs -sSf | sh
info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargo's bin 
directory, located at:

  /Users/user/.cargo/bin

This path will then be added to your PATH environment variable by modifying the
profile files located at:

  /Users/user/.profile
  /Users/user/.bash_profile

You can uninstall at any time with rustup self uninstall and these changes will
be reverted.

Current installation options:

   default host triple: x86_64-apple-darwin
     default toolchain: stable
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
1

info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2018-01-04, rust version 1.23.0 (766bd11c8 2018-01-01)
info: downloading component 'rustc'
 35.9 MiB /  35.9 MiB (100 %)  19.7 MiB/s ETA:   0 s                
info: downloading component 'rust-std'
 49.1 MiB /  49.1 MiB (100 %)  20.8 MiB/s ETA:   0 s                
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: default toolchain set to 'stable'

  stable installed - rustc 1.23.0 (766bd11c8 2018-01-01)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH 
environment variable. Next time you log in this will be done automatically.

To configure your current shell run source $HOME/.cargo/env
MacBook-Pro:~ user$  rustup self uninstall


Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove $HOME/.cargo/bin 
from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
info: removing cargo home
info: removing rustup binaries
error: could not remove 'cargo_home' directory: '/Users/user/.cargo'
info: caused by: No such file or directory (os error 2)

Most helpful comment

Hit for this today.

What it make it worse, is that rustup is _deleted before_. So run again:

sudo rustup self uninstall
sudo: rustup: command not found

I totally expect the "uninstaller" is the _last_ program to go...

All 16 comments

Same issue. Reproducible every time.

I've been digging some code. The error string is tied to the RemovingDirectory error. This error seems to lead to remove_dir(). Though, I'm not sure if and why fs::symlink_metadata() or remove_dir_all::remove_dir_all() fail.

Whats worse: As a user I don't know how incomplete the uninstallation is 馃憥

@schulzch I've been digging code too, and found the library export std::fs::remove_dir_all() as remove_dir_all::remove_dir_all() for non Windows environment.

When I build rustup from source code using toolchain same version as release build and execute the binary, this error never happened. Very strange.

Another thing thats strange is the dead link to cargo in the comment in remove_dir() and the potentially moved version looks quite different:

https://github.com/rust-lang/cargo/blob/e4ee9017ced76a59e374eccb0972eb4db3a2ccfe/src/cargo/util/paths.rs#L199-L251

I don't have a mac to reproduce this on, would appreciate someone taking a look at this!

@retlat are you definitely building with the same versions of dependencies as well?

Nowadays, you can run macOS inside of VirtualBox and some friendly guy provided an ISO for people without access to the Mac App Store.

What else can I do for you? 馃槃

@Diggsey sorry, I don't remember the dependencies were definitely same versions.
I'll try to build again when I have time.

@Diggsey I try again.
Dependencies are exactly same version but reproduce cargo_home directory remove error.

And I run test with this command and got failed.
This test succeeded in release build.

Following is test output.

failures:

---- uninstall_self_delete_works stdout ----
    running "/path/to/rustup.rs/target/x86_64-apple-darwin/tests/rustup-exe.ee5Uzgg4sWli/rustup" "set" "host" "x86_64-apple-darwin"
status: exit code: 1
----- stdout

----- stderr
error: Found argument 'host' which wasn't expected, or isn't valid in this context

USAGE:
    rustup set <SUBCOMMAND>

For more information try --help

running "/path/to/rustup.rs/target/x86_64-apple-darwin/tests/rustup-exe.ee5Uzgg4sWli/rustup-init" "-y"
status: exit code: 0
----- stdout

  stable installed - 1.1.0 (hash-s-2)


----- stderr
info: syncing channel updates for 'stable-x86_64-apple-darwin'
info: latest update on 2015-01-02, rust version 1.1.0
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: default toolchain set to 'stable'

out: 
err: info: removing rustup home
info: removing cargo home
info: removing rustup binaries
error: could not remove 'cargo_home' directory: '/path/to/rustup.rs/target/x86_64-apple-darwin/tests/rustup-cargo.QbgT9BhsPIYb/ch'
info: caused by: No such file or directory (os error 2)

thread 'uninstall_self_delete_works' panicked at 'assertion failed: out.status.success()', tests/cli-self-upd.rs:257:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    uninstall_self_delete_works

test result: FAILED. 56 passed; 1 failed; 4 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--test cli-self-upd'

Hit for this today.

What it make it worse, is that rustup is _deleted before_. So run again:

sudo rustup self uninstall
sudo: rustup: command not found

I totally expect the "uninstaller" is the _last_ program to go...

when i do
sudo rustup self uninstall
errors out:
error: missing key: 'version'

@robomantis19 If you installed with sudo I'd be surprised. Don't use sudo with rustup.

I have tested current release on the macOS 10.13.7, 10.14.6 and 10.15.7.
On 10.15.7 every trials are succeeded, but trials on others are failed.
Therefore I think rustup is not the cause of uninstalling failure, so I'll close this issue.

I think my problem was unique my disk ran out of space mid install and then when I deleted some files to clear space and reinstall or even uninstall with rustup, it errored
error: with missing key: 'version'

my solution was to reinstall my operating system and then it worked.

@robomantis19 thats worth a new bug: writing metadata files atomically is probably something we should be doing.

I think my problem was unique my disk ran out of space mid install and then when I deleted some files to clear space and reinstall or even uninstall with rustup, it errored
error: with missing key: 'version'

my solution was to reinstall my operating system and then it worked.

I've run into this as well. Please tell me someone has logged this bug or found a solution other than reinstalling macOS.

I just renamed ~/.rustup to something else and then I was good to go.

Was this page helpful?
0 / 5 - 0 ratings