vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

VS Code Dev Container error when using WSL.

Open SaurabhHarwande opened this issue 1 year ago • 8 comments

I am trying to setup Dev Containers on my windows machine using WSL 2 hosted Alpine distro. The Apline distro has podman setup locally and am able to run containers on it.

Settings used on VS Code are as follows :

{
	"dev.containers.dockerPath": "podman",
	"dev.containers.executeInWSL": true,
	"dev.containers.executeInWSLDistro": "Alpine"
}

Trying to open a folder inside the container results in error. The set up details and logs are as given below:

  • VSCode Version: 1.85.1
  • Local OS Version: Windows 10 build 19045.3803
  • Remote OS Version: WSL Alpine
  • Remote Extension/Connection Type: Containers
  • Logs:
[384 ms] Dev Containers 0.329.0 in VS Code 1.85.1 (0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2).
[382 ms] Start: Run: wsl -d Alpine -e wslpath -u C:\Program Files\Microsoft VS Code
[4130 ms] Start: Run: wsl -d Alpine -e /bin/sh -c cd '/mnt/c/Program Files/Microsoft VS Code' && /bin/sh
[4162 ms] Start: Run in host: id -un
[4613 ms] root
[4614 ms] 
[4616 ms] Start: Run in host:  (command -v getent >/dev/null 2>&1 && getent passwd 'root' || grep -E '^root|^[^:]*:[^:]*:root:' /etc/passwd || true)
[4661 ms] Start: Run in host: echo ~
[4663 ms] /root
[4664 ms] 
[4666 ms] Start: Run in host: test -x '/root/.vscode-remote-containers/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/node'
[4674 ms] 
[4675 ms] 
[4676 ms] Start: Run in host: test -f '/root/.vscode-remote-containers/dist/vscode-remote-containers-server-0.329.0.js'
[4680 ms] 
[4680 ms] 
[4684 ms] userEnvProbe: loginInteractiveShell (default)
[4684 ms] userEnvProbe: not found in cache
[4685 ms] userEnvProbe shell: /bin/ash
[5636 ms] userEnvProbe PATHs:
Probe:     '/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/Python311/Scripts/:/mnt/c/Program Files/Python311/:/mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/1E/Client/Extensibility/NomadBranch:/mnt/c/Program Files (x86)/Riverbed/Steelhead Mobile/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn/:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/DTS/Binn/:/mnt/c/Program Files/Microsoft/Azure Functions Core Tools/:/mnt/c/Program Files/Amazon/AWSCLIV2/:/mnt/c/Program Files/Android/cmdline-tools/latest/bin:/mnt/c/Program Files/Java/jdk/jdk-20.0.1/bin:/mnt/c/Program Files/Android/platform-tools:/mnt/c/Program Files/Kubernetes:/mnt/c/Program Files/Hashicorp/Terraform:/mnt/c/Program Files/Spring/spring-3.1.2/bin:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/DigitalOcean/doctl:/mnt/c/Program Files/Go/bin:/mnt/c/Users/saurabh.harwande/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/saurabh.harwande/.dotnet/tools:/mnt/c/Users/saurabh.harwande/AppData/Roaming/npm:/mnt/c/Users/saurabh.harwande/go/bin:/usr/local/go/bin:/root/dotnet-root:/root/dotnet-root/tools'
Container: None
[6097 ms] Start: Run in Host: podman version --format {{.Server.APIVersion}}
[7110 ms] 4.1.0
[18081 ms] Start: Run: wsl -d Alpine -e wslpath -u c:\Users\saurabh.harwande\source\DevContainers\vscode-remote-try-node
[18949 ms] Start: Run: wsl -d Alpine -e /bin/sh -c cd '/mnt/c/Users/saurabh.harwande/source/DevContainers/vscode-remote-try-node' && /bin/sh
[18972 ms] Start: Run in host: id -un
[19472 ms] root
[19473 ms] 
[19474 ms] Start: Run in host:  (command -v getent >/dev/null 2>&1 && getent passwd 'root' || grep -E '^root|^[^:]*:[^:]*:root:' /etc/passwd || true)
[19484 ms] Start: Run in host: echo ~
[19488 ms] /root
[19489 ms] 
[19490 ms] Start: Run in host: test -x '/root/.vscode-remote-containers/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/node'
[19492 ms] 
[19493 ms] 
[19497 ms] Start: Run in host: test -f '/root/.vscode-remote-containers/dist/vscode-remote-containers-server-0.329.0.js'
[19499 ms] 
[19500 ms] 
[19502 ms] userEnvProbe: loginInteractiveShell (default)
[19503 ms] userEnvProbe: not found in cache
[19504 ms] userEnvProbe shell: /bin/ash
[19932 ms] userEnvProbe PATHs:
Probe:     '/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/Python311/Scripts/:/mnt/c/Program Files/Python311/:/mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/1E/Client/Extensibility/NomadBranch:/mnt/c/Program Files (x86)/Riverbed/Steelhead Mobile/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn/:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/DTS/Binn/:/mnt/c/Program Files/Microsoft/Azure Functions Core Tools/:/mnt/c/Program Files/Amazon/AWSCLIV2/:/mnt/c/Program Files/Android/cmdline-tools/latest/bin:/mnt/c/Program Files/Java/jdk/jdk-20.0.1/bin:/mnt/c/Program Files/Android/platform-tools:/mnt/c/Program Files/Kubernetes:/mnt/c/Program Files/Hashicorp/Terraform:/mnt/c/Program Files/Spring/spring-3.1.2/bin:/mnt/c/Program Files/nodejs/:/mnt/c/Program Files/DigitalOcean/doctl:/mnt/c/Program Files/Go/bin:/mnt/c/Users/saurabh.harwande/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/saurabh.harwande/.dotnet/tools:/mnt/c/Users/saurabh.harwande/AppData/Roaming/npm:/mnt/c/Users/saurabh.harwande/go/bin:/usr/local/go/bin:/root/dotnet-root:/root/dotnet-root/tools'
Container: None
[20050 ms] Start: Run in Host: wslpath -w c:/Users/saurabh.harwande/source/DevContainers/vscode-remote-try-node
[20831 ms] Command failed: ls -a c:/Users/saurabh.harwande/source/DevContainers/vscode-remote-try-node
[20832 ms] ls: c:/Users/saurabh.harwande/source/DevContainers/vscode-remote-try-node: No such file or directory
[20832 ms] Exit code 1

Looks like we are trying to run ls for a Windows local path on a WSL 2 host distro. Maybe using wslpath -u instead of wslpath -w should help?

Steps to Reproduce:

  1. Clone the following repository https://github.com/microsoft/vscode-remote-try-node.git
  2. Install Dev Containers extension for VS code
  3. Press F1 and select Dev Containers: Open Folder in Container
  4. Select the cloned folder as target

Does this issue occur when you try this locally?: No Does this issue occur when you try this locally and all extensions are disabled?: No

SaurabhHarwande avatar Jan 03 '24 09:01 SaurabhHarwande

Maybe try to upgrade your extension, or downgrade to v0.309.0

https://github.com/microsoft/vscode-remote-release/issues/9064#issuecomment-1747913455

Qwarctick avatar Feb 07 '24 17:02 Qwarctick

This also happens on win11 and wsl2 and 0.349.0. Rollback to 0.309.0 fixed it. The command run manually in wsl: ls -a $(wslpath -w c:/Users/me/Desktop/devc) (fails) ls -a $(wslpath -u c:/Users/me/Desktop/devc) (works)

dwidge avatar Mar 13 '24 12:03 dwidge

I'm also getting the same issue, but the part that I find interesting, is that when I click the Reopen in Container: image It then fails with the "An error occurred setting up the container" dialog, and the output terminal showing the ls -a c:/users.... That is standard. I then click OK on this dialog: image And then Ctrl+Shift+P and run "Dev Containers: Reopen in Container"... and it works!?!? image

I have no idea why it responds differently, but at least it works. As an FYI, this is with Dev Containers v0.366.0 (pre-release) and VSCode 1.89.1.

barrymw avatar May 22 '24 09:05 barrymw

Seeing this on v0.362.0 as well. Using the Dev Containers: Reopen in Container command negates the issue on this version as well.

solidDoWant avatar Jun 02 '24 21:06 solidDoWant

same here with v0.369.0. Also using the Dev Containers: Reopen in Container command negates the issue on this version as well.

lucabandMSFT avatar Jun 28 '24 03:06 lucabandMSFT

Same here. A rollback to version 0.309 works and barrymw's strange solution with the latest version of the extension also works

vnabet avatar Jul 05 '24 13:07 vnabet

My env crashes 1 step earlier just after wslpath -w /home/user/{{removed}} but no indication about the error itself, the wslpath returns \\wsl.localhost\Ubuntu-22.04\home\user\{{removed}}.

Switching from v0.375.1 (current) to v0.377.0 (pre-release) fixed this for me.

tempcvrohch avatar Jul 15 '24 12:07 tempcvrohch