Access is denied error on juliaup add on Windows
Due to my antivirus real time protection juliaup add often fails. It looks like this:
❯ juliaup add pr56708
Installing Julia pr56708-win64
Error: Access is denied. (os error 5)
(7 more unsuccesful attempts)
❯ juliaup add pr56708
Installing Julia pr56708-win64
In my antivirus I see it is scanning some of the 5000 files in .julia/juliaup/julia-temp-*. It fails after successfully downloading the binary, and after each such error it leaves a complete julia-temp-* folder behind, which also doesn't get removed with juliaup gc (I guess it should?).
It seems the operation that is failing is renaming the directory to (in this case) julia-pr56708.
Pkg gave me and others similar trouble, but that has been addressed by https://github.com/JuliaLang/Pkg.jl/pull/4001. Perhaps a similar strategy would be good for juliaup.
EDIT: this now gives a better error:
❯ juliaup up
Checking for new Julia versions
Updating channel 1.11
Installing Julia 1.11.3+0.x64.w64.mingw32
Error: Failed to install '1.11.3+0.x64.w64.mingw32' while updating channel '1.11'.
Caused by:
0: Failed to extract downloaded file from url `https://julialang-s3.julialang.org/bin/winnt/x64/1.11/julia-1.11.3-win64.tar.gz`.
1: failed to unpack `julia-1.11.3/share/julia/base/abstractarray.jl` into `a:\.julia\juliaup\julia-1.11.3+0.x64.w64.mingw32\share\julia\base\abstractarray.jl`
2: Access is denied. (os error 5)
This thread might help as it did for me: https://julialang.slack.com/archives/C67910KEH/p1760369654918229
Indeed, if there are permission errors it can make sense to remove the target directory. In my case there are no permission errors and the target dir is never created, it just fails on the rename:
https://github.com/JuliaLang/juliaup/blob/b38a83903450ce1ccda23515a4a0c95594ce0817/src/operations.rs#L619-L623
Besides the Pkg retry linked above it seems that rustup also uses a retry for the same use case: https://github.com/rust-lang/rustup/pull/1873