Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust can't delete it's own tmp #3465

Closed
DasLixou opened this issue Aug 24, 2023 · 11 comments
Closed

Rust can't delete it's own tmp #3465

DasLixou opened this issue Aug 24, 2023 · 11 comments
Labels

Comments

@DasLixou
Copy link

DasLixou commented Aug 24, 2023

Problem

Just can't delete its own temp folder on Windows. It panics:
thread 'main' panicked at 'Unable to clean up C:\Users\lixou\.rustup\tmp: Os { code: 5, kind: PermissionDenied, message: "Zugriff verweigert" }', src\utils\utils.rs:650:13
I installed rustup via the exe setup.

Steps

Install rustup via the exe setup on windows.

Possible Solution(s)

No response

Notes

I had this for a while now, thought of reporting the bug

Rustup version

rustup 1.26.0 (5af9b9484 2023-04-05)

Installed toolchains

Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\lixou\.rustup

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc

installed targets for active toolchain
--------------------------------------

thumbv6m-none-eabi
thumbv7em-none-eabihf
x86_64-pc-windows-msvc

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.72.0 (5680fa18f 2023-08-23)
@DasLixou DasLixou added the bug label Aug 24, 2023
@rbtcollins
Copy link
Contributor

Thanks for reporting it. This is definitely not the normal case. Can you please see if there is a file left in the referenced tmp dir after that error? Also what anti-virus / anti-malware software do you have in use?

@DasLixou
Copy link
Author

DasLixou commented Sep 4, 2023

@rbtcollins sorry having you waiting for so long. I only use default windows defender. Indeed, there is a file called feeatnvdkbrj7yrw_file still inside the tmp folder.

@rbtcollins
Copy link
Contributor

My turn to apologise :).

Can you examine the permissions on that file (or if its gone, whatever files are present, and if no files, tmp itself)?

e.g. this is what I see:

> cd .rustup
>icacls tmp
tmp NT AUTHORITY\SYSTEM:(OI)(CI)(F)
    BUILTIN\Administrators:(OI)(CI)(F)
    LIFELESSTR2\robertc:(OI)(CI)(F)

@DasLixou
Copy link
Author

I just deleted tmp manually ._. any way to like.. get it back? could i maybe install another target or so?

@rbtcollins
Copy link
Contributor

it might be in your Deleted Files / Recycled folder, depending on how you deleted it. I'm not sure if we'll learn much from it there, it might have reset the file ACLS - but perhaps it didn't, worth giving it a go.

What I'm trying to figure out is whether the error you are getting is:

  • permissions based
  • something like an open / running process causing the failure, even though the permissions are legitimate

Also - what OS version do you have? (just the major - e.g. 7/10/11)

@DasLixou
Copy link
Author

it might be in your Deleted Files / Recycled folder, depending on how you deleted it. I'm not sure if we'll learn much from it there, it might have reset the file ACLS - but perhaps it didn't, worth giving it a go.

What I'm trying to figure out is whether the error you are getting is:

  • permissions based

  • something like an open / running process causing the failure, even though the permissions are legitimate

Also - what OS version do you have? (just the major - e.g. 7/10/11)

It's windows 11. I'm running it inside of vs code but i always stop the language server on update

@RossSmyth
Copy link

Hello, I am experiencing this issue as well. I may have seen it before but previously I didn't really pay that close of attention to rustup updating. This is on Windows 10 Pro 10.0.19045.

PS C:\Users\rsmyth\.rustup\tmp> rustup -v
rustup 1.26.0 (5af9b9484 2023-04-05)
The Rust toolchain installer

Condensed output:

PS C:\Users\rsmyth\Documents\Project> rustup update
...
thread 'main' panicked at 'Unable to clean up C:\Users\rsmyth\.rustup\tmp: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }', src\utils\utils.rs:650:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Full output for the sake of it:

rustup update output
PS C:\Users\rsmyth\Documents\Project> rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2023-12-07, rust version 1.74.1 (a28077b28 2023-12-04)
info: downloading component 'rust-src'
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 14.4 MiB /  14.4 MiB (100 %)   4.7 MiB/s in  3s ETA:  0s
info: downloading component 'rust-std'
 17.9 MiB /  17.9 MiB (100 %)   5.4 MiB/s in  3s ETA:  0s
info: downloading component 'rustc'
 58.4 MiB /  58.4 MiB (100 %)   4.6 MiB/s in 12s ETA:  0s
info: downloading component 'rustfmt'
info: removing previous version of component 'rust-src'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'rust-src'
  2.4 MiB /   2.4 MiB (100 %)   2.0 MiB/s in  7s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.4 MiB /  14.4 MiB (100 %) 806.4 KiB/s in 50s ETA:  0s    
info: installing component 'rust-std'
 17.9 MiB /  17.9 MiB (100 %)   9.4 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 58.4 MiB /  58.4 MiB (100 %)  10.0 MiB/s in  6s ETA:  0s
info: installing component 'rustfmt'
warning: could not delete temp file: C:\Users\rsmyth\.rustup\tmp\_zqt_n58jgmo_epw_file
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: latest update on 2023-12-07, rust version 1.76.0-nightly (1fdfe1234 2023-12-06)
info: downloading component 'cargo'
  6.7 MiB /   6.7 MiB (100 %)   3.9 MiB/s in  2s ETA:  0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 14.7 MiB /  14.7 MiB (100 %)   3.8 MiB/s in  4s ETA:  0s
info: downloading component 'rust-std'
 18.3 MiB /  18.3 MiB (100 %)   4.1 MiB/s in  4s ETA:  0s
info: downloading component 'rustc'
 59.2 MiB /  59.2 MiB (100 %)   4.8 MiB/s in 12s ETA:  0s
info: downloading component 'rustfmt'
info: removing previous version of component 'cargo'
info: removing previous version of component 'clippy'
info: removing previous version of component 'rust-docs'
info: removing previous version of component 'rust-std'
info: removing previous version of component 'rustc'
info: removing previous version of component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.7 MiB /  14.7 MiB (100 %) 806.4 KiB/s in 48s ETA:  0s    
info: installing component 'rust-std'
 18.3 MiB /  18.3 MiB (100 %)   9.4 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 59.2 MiB /  59.2 MiB (100 %)  10.3 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: checking for self-update

   stable-x86_64-pc-windows-msvc updated - rustc 1.74.1 (a28077b28 2023-12-04) (from rustc 1.72.0 (5680fa18f 2023-08-23))
  nightly-x86_64-pc-windows-msvc updated - rustc 1.76.0-nightly (1fdfe1234 2023-12-06) (from rustc 1.74.0-nightly (a991861ec 2023-09-05))

info: cleaning up downloads & tmp directories
thread 'main' panicked at 'Unable to clean up C:\Users\rsmyth\.rustup\tmp: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }', src\utils\utils.rs:650:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Next, I tried using an admin powershell with full details:

PS C:\WINDOWS\system32> $Env:RUST_BACKTRACE = "full"
PS C:\WINDOWS\system32> rustup update
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: syncing channel updates for 'nightly-x86_64-pc-windows-msvc'
info: checking for self-update

   stable-x86_64-pc-windows-msvc unchanged - rustc 1.74.1 (a28077b28 2023-12-04)
  nightly-x86_64-pc-windows-msvc unchanged - rustc 1.76.0-nightly (1fdfe1234 2023-12-06)

info: cleaning up downloads & tmp directories
thread 'main' panicked at 'Unable to clean up C:\Users\rsmyth\.rustup\tmp: Os { code: 5, kind: PermissionDenied, message: "Access is denied." }', src\utils\utils.rs:650:13
stack backtrace:
   0:     0x7ff6b32f92e3 - <unknown>
   1:     0x7ff6b2f28ddb - <unknown>
   2:     0x7ff6b32d4ae1 - <unknown>
   3:     0x7ff6b32fdf2b - <unknown>
   4:     0x7ff6b32fdaf7 - <unknown>
   5:     0x7ff6b32fd6f5 - <unknown>
   6:     0x7ff6b32fe79d - <unknown>
   7:     0x7ff6b32fe4f6 - <unknown>
   8:     0x7ff6b32fe43f - <unknown>
   9:     0x7ff6b32fe414 - <unknown>
  10:     0x7ff6b3426615 - <unknown>
  11:     0x7ff6b32b1ee5 - <unknown>
  12:     0x7ff6b327a597 - <unknown>
  13:     0x7ff6b3263447 - <unknown>
  14:     0x7ff6b2e82cf2 - <unknown>
  15:     0x7ff6b2e81006 - <unknown>
  16:     0x7ff6b2e83bd0 - <unknown>
  17:     0x7ff6b33f848c - <unknown>
  18:     0x7ff87d1d7344 - BaseThreadInitThunk
  19:     0x7ff87ea226b1 - RtlUserThreadStart

And as suggested above:

PS C:\Users\rsmyth\.rustup> icacls tmp
tmp NT AUTHORITY\SYSTEM:(OI)(CI)(F)
    BUILTIN\Administrators:(OI)(CI)(F)
    COMAPNY_DOMAIN\rsmyth:(OI)(CI)(F)

Successfully processed 1 files; Failed processing 0 files

Where COMPANY_DOMAIN is my company's domain, as this is a work computer. I just changed it.

The details of the file within:

PS C:\Users\rsmyth\.rustup> cd tmp
PS C:\Users\rsmyth\.rustup\tmp> ls


    Directory: C:\Users\rsmyth\.rustup\tmp


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----          9/6/2023   4:12 PM        1286656 _zqt_n58jgmo_epw_file


PS C:\Users\rsmyth\.rustup\tmp> icacls .\_zqt_n58jgmo_epw_file
.\_zqt_n58jgmo_epw_file NT AUTHORITY\SYSTEM:(F)
                        BUILTIN\Administrators:(F)
                        COMAPNY_DOMAIN\rsmyth:(F)

Successfully processed 1 files; Failed processing 0 files

The file is still there, so let me know if there is anything else I can do. Looking at

rustup/src/utils/utils.rs

Lines 647 to 654 in 5af9b94

pub(crate) fn delete_dir_contents(dir_path: &Path) {
match remove_dir_all::remove_dir_contents(dir_path) {
Err(e) if e.kind() != io::ErrorKind::NotFound => {
panic!("Unable to clean up {}: {:?}", dir_path.display(), e);
}
_ => {}
}
}

I don't see anything particularly obvious.

@RossSmyth
Copy link

RossSmyth commented Dec 7, 2023

Ah, I ran the original rustup update command in a VS Code terminal. The admin shell was a separate Powershell window. I closed VS Code and tried again and it worked without panicking. So my guess is something with RA or something prevented it from being deleted.

@Goozoon
Copy link

Goozoon commented Feb 8, 2024

Ah, I ran the original rustup update command in a VS Code terminal. The admin shell was a separate Powershell window. I closed VS Code and tried again and it worked without panicking. So my guess is something with RA or something prevented it from being deleted.

Yes, I had the same problem. Project opened in VSCode and tried to run rustup update in separate terminal
Closing VSCode helped to Update

@rami3l
Copy link
Member

rami3l commented Feb 9, 2024

@RossSmyth @Goozoon Thanks! Similar to #3660, this seems to be another example of #988.

@rami3l
Copy link
Member

rami3l commented Feb 13, 2024

Closing as a duplicate of #988.

@rami3l rami3l closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants