[win] Installation permissions breaks over time

tl;dr On a few Wiindows systems it seems like write permissions can break under .cargo/.rustup sometimes, causing writes to fail. It happens rarely, but we're seeing it more often on one Windows system when updating the registry index. Anyone know what could be causing this?

This problem is getting annoying enough for me to feel that I don't want to live with it any more -- and I'm wondering if anyone knows what may be causing it.

In short the issue is that the permissions under $HOME/.cargo, $HOME/.rustup can suddenly degenerate, causing attempted write access (i.e. updates) to fail with a permission denied error.

This started quite a while back; on one system we could no longer run rustup update. The error clearly stated that it was trying to update certain files but wasn't allowed to. I searched around a little and found that there were others who had run into similar issues, and someone said "copy the file to a new file, remove the old one and then rename the copy to the original". That kind of worked, but the error just moved to the next file. I fixed something but the next file would fail with the same error. It soon became apparent that every file had broken permissions. It became too much work to try to fix it file-by-file, so I simply removed Rust completely and reinstalled it using the rustup installer, and the problems seemingly went away.

That was the most extreme case -- it seemed like the entire directory tree broke somehow. But since then we've had other directories/components experience the same problem on different Windows computers. (Never seen it on macOS or Linux though).

The thing that has started happening more lately is that I want to update the index manually on login; I have a login script (running as the user) that runs:

Set-Location -Path "$HOME/.cargo/registry/index/github.com-1ecc6299db9ec823"
& git fetch https://github.com/rust-lang/crates.io-index refs/heads/master:refs/remotes/origin/master

... and the problem is that if this permission problem occurs git will stop with an error message and ask whether to retry the operation or move on. Retrying doesn't work (same error over and over again). Aborting and running again yields the same issue. So what I've learned to do is that - if/when it happens again - I completely remove $HOME/.cargo/registry/index/github.com-1ecc6299db9ec823 and perform some action to recreate it (like build a crate with dependencies).

It's clearly not only me having this problem, and we've seen it on at least three Windows systems, possibly four. When searching for the specific error it's clear others have encountered it, but the ones I have found don't really mention that it happens multiple times, but they have seen it once at least. But I didn't see any solutions; only workarounds.

I know others have encountered this problem (I'm assuming it's a problem, not several), although seemingly milder versions of it. But has anyone here seen it? Does anyone know what could be causing this? (Like I mentioned earlier, I've lived with it for a long time, but for some reason updating the cargo registry index has lately triggered this far more often than it used to, which is annoying).

Potentially relevant:

  • Windows/amd64 10 Pro
  • Has happened with stable and nightly toolchains
  • Installed Rust using rustup
  • msvc version
  • Has happened before running the update from a login script (so it's not because it is running from a login script)

When it happens again, could you inspect the file permissions with a tool like icacls to see which file/permissions are giving the issue?

I will!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.