# fresh install fails on Windows: "error: could not rename component file from '... \rust-docs\share/doc/rust/html' ..." #1912

Open
opened this issue Jun 25, 2019 · 20 comments

### s-n-ushakov commented Jun 25, 2019

 Problem A fresh install of stable build fails on Windows 8.1 with message "error: could not rename component file from '... \rust-docs\share/doc/rust/html' ...". Expected behavior would be the install to be successful :) Steps Check Windows version is 8.1 (not checked for other versions) Ensure %USERPROFILE%\.rustup and %USERPROFILE%\.cargo folders do not exist Download the latest stable rustup-init.exe file (1.35.0 of 2019-05-23) and run it under normal (non-admin) user without elevating user rights. Respond with "1" to the question regarding "Current installation options" Wait until the install fails with message "error: could not rename component file from '... \rust-docs\share/doc/rust/html' ..." C:\Users\ushakov\Documents\-work\Downloads\www.rust-lang.org>rustup-init.exe 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: C:\Users\ushakov\.cargo\bin This path will then be added to your PATH environment variable by modifying the HKEY_CURRENT_USER/Environment/PATH registry key. You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-pc-windows-msvc 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-pc-windows-msvc' info: latest update on 2019-05-23, rust version 1.35.0 (3c235d560 2019-05-20) info: downloading component 'rustc' 60.0 MiB / 60.0 MiB (100 %) 8.0 MiB/s in 9s ETA: 0s info: downloading component 'rust-std' 53.1 MiB / 53.1 MiB (100 %) 8.3 MiB/s in 7s ETA: 0s info: downloading component 'cargo' info: downloading component 'rust-docs' 10.3 MiB / 10.3 MiB (100 %) 9.3 MiB/s in 1s ETA: 0s info: installing component 'rustc' 60.0 MiB / 60.0 MiB (100 %) 7.7 MiB/s in 8s ETA: 0s info: installing component 'rust-std' 53.1 MiB / 53.1 MiB (100 %) 7.3 MiB/s in 15s ETA: 0s info: installing component 'cargo' 2.9 MiB / 2.9 MiB (100 %) 2.1 MiB/s in 6s ETA: 0s info: installing component 'rust-docs' 10.3 MiB / 10.3 MiB (100 %) 473.6 KiB/s in 1m 35s ETA: 0s info: rolling back changes error: could not rename component file from 'C:\Users\ushakov\.rustup\tmp\grl2pj2s61kwqrko_dir\rust-docs\share/doc/rust/html' to 'C:\Users\ushakov\.rustup\toolchains\stable-x86_64-pc-windows-msvc\share/doc/rust/html' info: caused by: Отказано в доступе. (os error 5) Press the Enter key to continue.  Possible Solution(s) A possible temporary workaround may be to run the installer with admin privileges, as per https://stackoverflow.com/questions/52542965/rust-installation-fails-on-windows-subsystem-for-linux-could-not-rename-compone/55373522#55373522 , that proved to work for me. Notes Output of rustup --version: rustup 1.18.3 (435397f48 2019-05-22) Output of rustup show: Default host: x86_64-pc-windows-msvc stable-x86_64-pc-windows-msvc (default) rustc 1.35.0 (3c235d560 2019-05-20) 

### s-n-ushakov added the bug label Jun 25, 2019

referenced this issue Jun 25, 2019
Collaborator

### rbtcollins commented Jun 25, 2019

 Thank you for generating this report. It does look to me like a probable anti-virus problem. You mentioned in 1723 that you have procmon traces - have a look in that at the time of the error, are there any other processes with handles open anywhere in that subdirectory? I'm happy to look through if you can upload the PML (as a zip/tar) to s3 or seed it as a torrent or some such...
Author

### s-n-ushakov commented Jun 26, 2019

 @rbtcollins I have placed the zipped PML log (11M) here: http://www.usn.pp.ru/tmp/rustup-init--procmon.2019-06-24.zip . Unfortunately could not find anything suspicious so far... Please let me know whether the log is good when your time allows...
Collaborator

### rbtcollins commented Jun 26, 2019

 The log doesn't have enough info in it (or its not what I think it is, or Defender's implementation has changed radically from Windows 8 to 10). So this is the event that fails: 5:03:57.3318549 PM 0.0137171 rustup-init.exe 12352 22804 SetRenameInformationFile C:\Users\ushakov\.rustup\tmp\grl2pj2s61kwqrko_dir\rust-docs\share\doc\rust\html ACCESS DENIED ReplaceIfExists: True, FileName: C:\Users\ushakov\.rustup\toolchains\stable-x86_64-pc-windows-msvc\share\doc\rust\html  But there are no events in the trace from other processes than rustup-init.exe - I suspect you've got a filter on the process name. Check that you aren't filtering for just rustup-init.exe in the filter dialog when you make the trace - something like "Path contains .rustup" would be a good filter - the default filters to exclude procmon.exe itself and so on are fine, but we do want to see activity from other processes within this directory structure. After you've done the trace and saved the file, you can then edit the filter and add filter to exclude events from rustup-init.exe - I'd expect that then you'd see defender or whatever is causing the issue operating on those files. I would find the event in the first place by adding a filter on result for 'ACCESS DENIED' and then using the microsecond timestamp to find the event in context when that filter is disabled (or clicking on the event, then removing the filter may keep you on it - the UI can be a bit flaky though so...).
Author

### s-n-ushakov commented Jun 27, 2019

 @rbtcollins I have finally managed to guess the time values to filter out all the events withing 2 sec timeframe around the failure event :) : All the excludes are the standard ones suggested by procmon, except the one of mine that restricts the time. Please find the resulting zipped PML log (0.5M) here: http://www.usn.pp.ru/tmp/rustup-init--procmon.2019-06-24--two-seconds-around.zip
Collaborator

### rbtcollins commented Jun 27, 2019

 Ok so thats super interesting, - definitely other processses in the trace, but none operating on .rustup files. I suspect we need to get into kernel tracing at this point - ETW / WPR https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh448205(v=win.10) - - basically looking for the cause of the access denied. Before doing that, please try building and running master - there's some unpacking IO changes that might make this better - or worse - and would allow me to make the following statement: We make that dir with the same code for both the binaries and docs, so either both should succeed or both should fail, which is why the third-party-process holding a handle open is the most likely scenario.
Author

### s-n-ushakov commented Jun 28, 2019

 @rbtcollins Ok, I'll see if I succeed with building the master on the weekend. Meanwhile could you describe your ideas on further troubleshooting in some more detail? What the next steps may look like, and how to proceed?
Collaborator

### rbtcollins commented Jun 28, 2019

 @s-n-ushakov basically we're at the edge of my ready-to-use knowledge, so I'm going to be vague. But something like: enable kernel event tracing on all file operations, run the failing scenario, disable event tracing, look through the trace which hopefully will have much more detail than procmon, because it wires into the kernel itself rather than purely userspace.

### EugeneChung commented Jul 5, 2019

 I tried to install rust by chocolatey and got the similar error. ...\rust-docs\share\doc\rust\html' is denied. After I turned off my vaccine program, it was successful.

### mpoullet commented Jul 7, 2019

 I have the same issue here with the Avira anti-virus. Turning off the "Real-Time Protection" before running rustup-init.exe makes it work.

### ctaggart commented Jul 12, 2019

 This failed about 5 times for me and then I found this thread. It worked after I deselected the box in the McAfee Access Protection Properties to "Prevent McAfee services from being stopped" and then stopped the McAfee McShield" service. It is also known as the "McAfee On-Access Scanner service". This was the error: info: installing component 'rust-docs' 11.3 MiB / 11.3 MiB (100 %) 355.2 KiB/s in 1m 28s ETA: 0s info: rolling back changes error: could not rename component file from 'C:\Users\taggac\.rustup\tmp\l2_bwq4ke00qaw9i_dir\rust-docs\share/doc/rust/html' to 'C:\Users\taggac\.rustup\toolchains\beta-x86_64-pc-windows-gnu\share/doc/rust/html' info: caused by: Access is denied. (os error 5) 
Author

### s-n-ushakov commented Aug 1, 2019

 @rbtcollins I have to confess that I failed to do the ETW / WPR exercise so far, as my HDD with Windows died. Sorry... Now I am busy with gradual migration to Ubuntu, so it is not very much likely that I will be able to add more to this investigation, at least in the near future. But it is good to know that numerous colleagues here are reporting their observations of problem correlation with antivirus software...

### 13webstreet commented Aug 12, 2019

 Hi. I confirm the same as the above. After turning off Avira antivirus it worked.

### kwaegel commented Aug 15, 2019

 Same. Turning off the McAfee On-Access Scanner fixed the Access is denied. (os error 5) message.
Collaborator

### kinnison commented Aug 20, 2019

 Badly behaved scan-on-write virus scanners are becoming a great pain to me. I wonder if there's any way we can detect and mitigate this.

### pitaj commented Aug 21, 2019

 If I could disable my anti-virus temporarily I'm sure it would fix this issue. However, at work I am unable to disable the anti-virus program. This makes it impossible for me to use rustup update. Is it possible to make it so rustup won't give up after the very first attempt at moving? Or give us an option to, instead of moving the files, try copying to destination and deleting from source instead?

### pitaj commented Aug 21, 2019

 Update: this was fixed for me by building from latest master (d62e504) I think this issue is actually fixed by the same fix for #1870
Collaborator

### kinnison commented Aug 22, 2019

 Handy to know, thanks @pitaj -- I hope to get a release done soonish that will therefore solve this a bit.

### refaelsh commented Aug 23, 2019

 I have the same problem. Corporate laptop with McAfee that can not be turn off. I need this release in order to start learning rust. Please hurry :-)

### refaelsh commented Aug 23, 2019

 @pitaj Can you please share the binary you've build from the latest master? I cant install rust because of this issue and I cant build the latest master because I don't have rust.

### refaelsh commented Aug 23, 2019

 Found a way: downloaded the latest master directly from the CI/CD server: here. I can now start learning rust` :-)