Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rust installation fails on Windows Subsystem for Linux: could not rename component file

I'm trying to install Rust on the Windows Subsystem for Linux (WSL) by running the following command which is provided officially here:

curl https://sh.rustup.rs -sSf | sh

I've installed Ubuntu from the Microsoft Store.

The problem is that the fails with 5 similar errors:

error: could not rename component file from '/home/thesdev/.rustup/tmp/glf5z1z643ehld0x_dir/bk' to '/home/thesdev/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/man'

...

error: failed to install component: 'rust-docs-x86_64-unknown-linux-gnu', detected conflict: '"share/doc/rust/html"'

Screenshot of the installation process

Screenshot is from VS Code. Trying it in the Ubuntu application results in the same errors.

like image 718
thesdev Avatar asked Sep 27 '18 18:09

thesdev


3 Answers

Apparently, you need to close Visual Studio Code and run the command directly at the WSL prompt. The underlying issue is among the most-encountered WSL bugs:

  • npm package fails to install "npm ERR! Error: EACCES: permission denied"
  • Unable to save file when inotify is in use (using Node)
  • EACCES when renaming folder that is being watched from nodejs

I wouldn't be surprised if virus scanners could trigger this as well, not just Visual Studio Code.

like image 183
Florian Weimer Avatar answered Nov 04 '22 13:11

Florian Weimer


After several failed installations with the same error, I had to nuke my .rustup directory. I then ran the Rust installer with sudo. I recommend also temporarily turning off your antivirus protection, as that seems to cause issues.

The entire sequence of commands:

$ sudo rm -rf ./home/<your_username>/.rustup
$ curl 'https://sh.rustup.rs' -sSf > rustinstall.sh
$ sudo ./rustinstall.sh -y
like image 34
weirdev Avatar answered Nov 04 '22 13:11

weirdev


It seems that adding sudo to the start of the command does the trick.

like image 1
thesdev Avatar answered Nov 04 '22 15:11

thesdev