dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
680 stars 64 forks source link

mingw unpacking fails with custom choosenimDir #252

Open pravic opened 3 years ago

pravic commented 3 years ago

Apparently, choosenim doesn't like when --choosenimDir points to another drive if it's different from TEMP:

set TEMP=c:\windows\temp
choosenim --firstInstall --choosenimDir:d:\nim\choosenim --debug

>      Error: Unable to extract. Error was 'Access is denied.
>        ... Additional info: "(\"C:\\\\WINDOWS\\\\TEMP\\\\nimarchive-3489535509\\\\mingw64\\\\bin\", \"d:\\\\nim\\\\choosenim\\\\toolchains\\\\mingw64\\\\bin\")"'.

On the same drive it's it works fine:

set TEMP=d:\nim\temp
mkdir %TEMP%
choosenim --firstInstall --choosenimDir:d:\nim\choosenim --debug
...
   Switched to Nim 1.4.4

Although it seems that it's a pain anyway to specify a custom directory for choosenim and nimble:

Sigh.

heinthanth commented 3 years ago

c:\windows is not accessible by default unless you run with administrator privileges.

dom96 commented 2 years ago

I assume this is because of simple permission problems. Closing.

pravic commented 2 years ago

c:\windows is not accessible by default unless you run with administrator privileges.

@heinthanth c:\windows isn't accessible for writing by default.

pravic commented 2 years ago

I assume this is because of simple permission problems. Closing.

@dom96 I suspect that choosenim was trying to move (aka rename) the unpacked directory - a quite common pattern to avoid unnecessary copy. But on Windows you can't move a directory to another drive, thus the access error.

Just a speculation but with a good chance of being true. Because c:\windows\temp is accessible for writing by anyone; moreover, choosenim does unpack its archives - it just fails to place them at the desired choosenimDir after downloading and unpacking.

dom96 commented 2 years ago

But on Windows you can't move a directory to another drive, thus the access error.

huh, haven't heard of this before. In any case, would appreciate your help on this one if this is important functionality for you.

pravic commented 2 years ago

https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-movefile

Basically, you can move a file to another drive (it will be a copy of file + delete), but you can't move a directory to another drive - it fails.

choosenim does unpack its archives - it just fails to place them at the desired choosenimDir after downloading and unpacking.

However, I see that you use https://github.com/dom96/choosenim/blob/1e9380741da1062e91fa7900b444211998441599/src/choosenimpkg/utils.nim#L103

So, the problem is somewhere else. I'll try to debug.