choosenim icon indicating copy to clipboard operation
choosenim copied to clipboard

mingw unpacking fails with custom choosenimDir

Open pravic opened this issue 3 years ago • 6 comments

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:

  • choosenim doesn't store the specified directory and always wants it in a command line
  • nimble uses its own nimble.ini and I have no idea how well it plays with choosenim

Sigh.

pravic avatar Mar 17 '21 09:03 pravic

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

heinthanth avatar Oct 05 '21 02:10 heinthanth

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

dom96 avatar Jul 06 '22 14:07 dom96

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

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

pravic avatar Jul 06 '22 16:07 pravic

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.

pravic avatar Jul 06 '22 16:07 pravic

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.

dom96 avatar Jul 06 '22 17:07 dom96

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.

pravic avatar Jul 07 '22 12:07 pravic