rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
5.84k stars 272 forks source link

WSL2 PATH Showing Incorrect Values #5359

Closed pchang388 closed 1 year ago

pchang388 commented 1 year ago

Actual Behavior

Rancher PATH appending in WSL2 Ubuntu 22.04 LTS is showing improper values. From a working machine I had with a similar setup, path has spaces and references the llinux bin, but when trying to install and configure on WSL2 on my corporate laptop, I see this

$ echo $PATH

/home/changpeter/.gvm/pkgsets/go1.21.0/global/bin:/home/changpeter/.gvm/gos/go1.21.0/bin:/home/changpeter/.gvm/pkgsets/go1.21.0/global/overlay/bin:/home/changpeter/.gvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program:Files:(x86)/RSA:SecurID:Token:Common:Files/RSA:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:Files/dotnet/:/mnt/c/Users/Peter_Chang1/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Peter_Chang1/AppData/Local/Programs/Microsoft:VS:Code/bin:/mnt/c/Users/Peter_Chang1/AppData/Local/Programs/Rancher:Desktop/resources/resources/win32/bin/:Desktop/resources/resources/linux/bin/:/snap/bin

We can see that spaces are replaced with ":" colons and the linux/bin directory appears to be partial instead of the full path. This causes me to not be able to use docker, helm, etc. provided by Rancher Desktop. I also see a strange issue that may be related when trying to go into those directories

/mnt/c/Users/Peter_Chang1/AppData/Local/Programs$ ls -lrt
total 0
drwxrwxrwx 1 changpeter changpeter 512 Aug 15 20:47  Common
drwxrwxrwx 1 changpeter changpeter 512 Aug 15 20:48 'Microsoft VS Code'
drwxrwxrwx 1 changpeter changpeter 512 Aug 15 20:59 'Rancher Desktop'

/mnt/c/Users/Peter_Chang1/AppData/Local/Programs$ cd 'Rancher Desktop'/
-bash: cd: too many arguments

/mnt/c/Users/Peter_Chang1/AppData/Local/Programs$ cd "Rancher Desktop"
-bash: cd: too many arguments

Steps to Reproduce

Result

Expected Behavior

Two issues:

Additional Information

$ cat /etc/wsl.conf

[boot]
systemd=true

Rancher Desktop Version

1.9.1

Rancher Desktop K8s Version

1.27.4

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Microsoft Windows 11 Enterprise [10.0.22000 Build 22000]

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

Yes VPN for corporate access, GlobalProtect VPN

mook-as commented 1 year ago

We have an awkward problem: we do not, in fact, attempt to append to your Ubuntu $PATH. We just add it to the Windows-side %PATH% (yes, the directory holding the Linux binaries) and hope that WSL will fix it up for us.

https://github.com/rancher-sandbox/rancher-desktop/blob/v1.9.1/build/wix/main.wxs#L130-L132

We do have some WSL integration stuff, but that runs processes and makes symlinks for docker plugins, but those shouldn't be affecting $PATH.

Also, we do have some $PATH munging on Linux/macOS, but that code shouldn't be running on Windows/WSL. (If we do run them, that would probably be a bug…)

Would you mind double checking the things in your .bashrc (maybe dumping $PATH as it runs) to ensure that the issue doesn't come from there? I realize that's probably not the answer you're looking for, but it's currently my best guess so far :)

pchang388 commented 1 year ago

No worries and thanks for your response, I did take another look and I found the issue:

I found the issue only occurs when I install GVM (golang version manager) on Ubuntu WSL2, it seems to change the PATH to include those colons and also does something very weird, I didn't save the log message unfortunately but can see this when I check the cd command

Normal response

$ type cd
cd is a shell builtin

When GVM installed:

cd is a function...

... some code for GVM specific operations ...

Essentially gvm at least in current latest version rewrites the cd builtin command with it's own for some reason which is not expected imo and makes it unusable. It shouldn't be doing that at all

pchang388 commented 1 year ago

Also I agree, I didn't think this was rancher doing it specifically since it was also happening for VS code, was just hoping someone had seen it before with a similar set up and knew how to resolve the issue

pchang388 commented 1 year ago

Think we can close this issue for now, hopefully it helps others also trying to get GVM to work, for now I will have to avoid it until it's resolved

mook-as commented 1 year ago

There seems to be multiple projects named gvm for managing golang versions, so it's unclear which one you're using :) If it's the moovweb one, scripts/function/munge_path#51 looks suspicious, but I don't seen an issue in their repository about spaces in $PATH.