-
Notifications
You must be signed in to change notification settings - Fork 655
Use short path for LIMA_HOME on windows #955
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
Conversation
What if your home directory is like |
C:\Users\Jan\Names>dir /x
Volume in drive C has no label.
Volume Serial Number is 5C37-CD74
Directory of C:\Users\Jan\Names
07/12/2022 10:10 PM <DIR> .
07/12/2022 10:10 PM <DIR> ..
07/12/2022 10:08 PM <DIR> BJRKLU~1 Björklund
07/12/2022 10:08 PM <DIR> ED60~1 漢字
0 File(s) 0 bytes
4 Dir(s) 41,248,669,696 bytes free
C:\Users\Jan\Names>perl -MWin32 -E "say Win32::GetShortPathName('Björklund')"
BJRKLU~1 Note that the creation of 8.3 short names can be disabled by NTFS on a per-volume basis (search for |
BTW, are you sure the problem is the long pathname and not some code page problem? It doesn't really matter though, as the short name algorithm always returns ASCII compatible strings, so you don't have to worry about encodings (unless people enable |
Actually I think the problem is related to how Go handles paths in the It could definitely be the unicode as well as the length, but the "fix" (workaround) would be the same either way. I'm not really a Windows person, I just saw this issue happening when it was run on a computer connected to the Active Directory. |
There is some confusion between $HOME and os.UserHomeDir, but the plan is to go with the windows default (%HOMEDRIVE%HOMEPATH%) i.e. for MSYS2 it will use something like But for MinGW64 it will use For corner cases, the user can override with $LIMA_HOME - maybe need something similar for the ssh variables (SSH_HOME?) EDIT: Updated to use the proper dos variables |
Note that On second thoughts, |
I was suspecting that "appdata" and friends had the same concern on Windows as on macOS, so didn't use them. Didn't expect home to fail too, but here we are. |
This seems to confirm that the issue is an encoding problem, and not the long filenames. I found this possible workaround (codepage cmd := exec.Command("powershell.exe", "-c", "chcp", "65001", ">", "$null", ";", command) Maybe even more gross than using short names. 😄 |
For myself, I only care about MSYS2 and MinGW64... It is nice if the old school Command Prompt works too (if it isn't too much hassle, like a simple .bat file or something) But I will not bother with Powershell, if the user is interested in Linux containers then I assume they have a decent shell. Something like this: https://dilbert.com/strip/1995-06-24 |
Actually, that is what is being done: https://pkg.go.dev/os#UserHomeDir
The rest was just my own guesses, based on variables (which I botched) |
This is not about the user using Powershell; it is just a way to switch the codepage before running the command. You can probably do the same thing with |
I still think for this particular case |
Other commands such as qemu-system-x86_64.exe don't work with C:\Users\AndersBjörklund, they need to use C:\Users\ANDERS~1 In theory they could have supported using UNC paths such as \\?\C:\Users\AndersBjörklund, but in practice they do not... Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
70c3f31
to
ac5f45c
Compare
We can have a poll later, but it is something nice about using the same path on all platforms ? Also, we are not using the proper XDG directories on linux either - but polluting the home dir... It was the same problem with And also with other traditional tools, like So I will stick with Note that we are using the system cache directory (which is in AppData). So at least the downloads will end up there. |
Other commands such as
qemu-system-x86_64.exe
don't work withC:\Users\AndersBjörklund
, they need to useC:\Users\ANDERS~1
In theory they could have supported using UNC paths such as
\\?\C:\Users\AndersBjörklund
, but in practice they do not...https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getshortpathnamew
GOOS=linux (host)
GOOS=windows (wine)