rancher-sandbox / rancher-desktop

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

WSL Integration breaks with apostrophe in user's home path #1943

Open jrodonnell opened 2 years ago

jrodonnell commented 2 years ago

Actual Behavior

Booting up Rancher Desktop for the first time, the WSL integration fails and K8s never comes up.

Steps to Reproduce

  1. Have an apostrophe in your home path, e.g. in my case "C:\Users\RileyO'Donnell"
  2. Launch Rancher Desktop

Result

UI shows this error:

Error Starting Kubernetes
Error: wsl.exe exited with code 1
Last command run:
wsl.exe --distribution rancher-desktop --exec /usr/local/bin/wsl-service docker start

Context:
Running provisioning scripts

Some recent logfile lines:
2022-03-31T18:57:43.275Z: Registered distributions: Ubuntu
2022-03-31T18:57:44.001Z: Registered distributions: Ubuntu
2022-03-31T18:57:48.136Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:48.310Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:48.310Z: Creating initial data distribution...
2022-03-31T18:57:52.129Z: Unmounting missing device /dev/sdf: 117 116 8:80 / /mnt/wsl/rancher-desktop/run/data rw,relatime shared:2 - ext4 /dev/sdf rw,discard,errors=remount-ro,data=ordered
2022-03-31T18:57:52.259Z: Did not find a valid mount, mounting /mnt/wsl/rancher-desktop/run/data
2022-03-31T18:57:55.295Z: Installing C:\Users\RileyO'Donnell\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin\trivy as /mnt/c/Users/RileyO'Donnell/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/trivy into /usr/local/bin/trivy ...
2022-03-31T18:58:15.207Z: WSL: executing: /usr/local/bin/wsl-service docker start: Error: wsl.exe exited with code 1

wsl.log shows this:

2022-03-30T02:05:35.180Z: Installing C:\Users\RileyO'Donnell\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin\trivy as /mnt/c/Users/RileyO'Donnell/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/trivy into /usr/local/bin/trivy ...
2022-03-30T02:06:05.264Z: WSL: executing: /usr/local/bin/wsl-service docker start: Error: wsl.exe exited with code 1
2022-03-30T02:12:14.698Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-30T02:12:15.255Z: /sbin/init exited gracefully.
2022-03-30T02:12:15.343Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-30T02:12:15.511Z: Registered distributions: Ubuntu
2022-03-30T02:12:16.011Z: Registered distributions: Ubuntu
2022-03-30T02:12:16.131Z: Registered distributions: Ubuntu,rancher-desktop,rancher-desktop-data
2022-03-30T02:12:16.413Z: Registered distributions: Ubuntu,rancher-desktop-data
2022-03-30T02:12:16.669Z: Registered distributions: Ubuntu
2022-03-30T02:12:16.781Z: Registered distributions: Ubuntu
2022-03-30T02:12:18.783Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-30T02:12:18.923Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-30T02:12:18.924Z: Creating initial data distribution...
2022-03-30T02:12:22.786Z: Unmounting missing device /dev/sde: 117 116 8:64 / /mnt/wsl/rancher-desktop/run/data rw,relatime shared:2 - ext4 /dev/sde rw,discard,errors=remount-ro,data=ordered
2022-03-30T02:12:22.915Z: Did not find a valid mount, mounting /mnt/wsl/rancher-desktop/run/data
2022-03-30T02:12:25.630Z: Installing C:\Users\RileyO'Donnell\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin\trivy as /mnt/c/Users/RileyO'Donnell/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/trivy into /usr/local/bin/trivy ...
2022-03-30T02:12:47.189Z: WSL: executing: /usr/local/bin/wsl-service docker start: Error: wsl.exe exited with code 1
2022-03-31T18:57:41.291Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:41.910Z: /sbin/init exited gracefully.
2022-03-31T18:57:42.009Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:42.163Z: Registered distributions: Ubuntu
2022-03-31T18:57:42.265Z: Registered distributions: Ubuntu
2022-03-31T18:57:42.405Z: Registered distributions: Ubuntu,rancher-desktop-data,rancher-desktop
2022-03-31T18:57:42.979Z: Registered distributions: Ubuntu,rancher-desktop-data
2022-03-31T18:57:43.275Z: Registered distributions: Ubuntu
2022-03-31T18:57:44.001Z: Registered distributions: Ubuntu
2022-03-31T18:57:48.136Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:48.310Z: Registered distributions: Ubuntu,rancher-desktop
2022-03-31T18:57:48.310Z: Creating initial data distribution...
2022-03-31T18:57:52.129Z: Unmounting missing device /dev/sdf: 117 116 8:80 / /mnt/wsl/rancher-desktop/run/data rw,relatime shared:2 - ext4 /dev/sdf rw,discard,errors=remount-ro,data=ordered
2022-03-31T18:57:52.259Z: Did not find a valid mount, mounting /mnt/wsl/rancher-desktop/run/data
2022-03-31T18:57:55.295Z: Installing C:\Users\RileyO'Donnell\AppData\Local\Programs\Rancher Desktop\resources\resources\linux\bin\trivy as /mnt/c/Users/RileyO'Donnell/AppData/Local/Programs/Rancher Desktop/resources/resources/linux/bin/trivy into /usr/local/bin/trivy ...
2022-03-31T18:58:15.207Z: WSL: executing: /usr/local/bin/wsl-service docker start: Error: wsl.exe exited with code 1

And wsl-exec.log shows this:

   OpenRC 0.44.7.86e4642bdd is starting up Linux 5.4.72-microsoft-standard-WSL2 (x86_64) [DOCKER]

 * /proc is already mounted
 * /run/openrc: creating directory
 * /run/lock: correcting mode
 * /run/lock: correcting owner
 * Caching service dependencies ...
 * /etc/fstab does not exist
Service `hwdrivers' needs non existent service `dev'
 [ ok ]
 * Generating machine-id ...
 [ ok ]
 * Starting busybox crond ...
 [ ok ]
 * /var/log/dnsmasq-generate.log: creating file
 * Generating dnsmasq configuration ...
 [ ok ]
 * /var/lib/misc/dnsmasq.leases: creating file
 * /var/lib/misc/dnsmasq.leases: correcting owner
 * Starting dnsmasq ...
 [ ok ]
 * Starting Rancher Desktop Guest Agent ...
 [ ok ]
 * Starting local ... [ ok ]

 * /etc/fstab does not exist
Service `hwdrivers' needs non existent service `dev'
 * Caching service dependencies ... [ ok ]
 * Starting Rancher Desktop Docker Daemon .../lib/rc/sh/openrc-run.sh: eval: line 1: syntax error: unterminated quoted string
 * ERROR: docker failed to start
 * Stopping local ... [ ok ]
Unregistering...

Unregistering...

Expected Behavior

Everything comes up and works!

Additional Information

Obvious workaround is to just change my account name, however this is happening on my work laptop and I do not have the permissions in my org to change my profile name ☹️ .

Rancher Desktop Version

1.2.1

Rancher Desktop K8s Version

1.22.7

Which container runtime are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Pro 21H2

What CPU architecture are you using?

x64

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

No response

Windows User Only

Microsoft Office profile is setting my local username so I can't change it.

ericpromislow commented 2 years ago

@jrodonnell I'm working on the fix, and it's not as straightforward as I was expecting. For one thing, our development environment doesn't work for users whose names contain a single quote!

But looking at the code, I'm wondering if you can get it to work if you switch to the containerd container engine? Different code paths, and I don't see the containerd code path carrying about the current home directory.

ericpromislow commented 2 years ago

And I see that k3s won't come up for the same reason as docker.