Skip to content
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

DISPLAY env does not get set correctly in container #7565

Closed
JohnDoe2991 opened this issue Nov 23, 2022 · 22 comments
Closed

DISPLAY env does not get set correctly in container #7565

JohnDoe2991 opened this issue Nov 23, 2022 · 22 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Milestone

Comments

@JohnDoe2991
Copy link

  • VSCode Version: 1.73.1
  • Local OS Version: Windows 10 21H2
  • Remote OS Version: Ubuntu 20.04
  • Remote Extension/Connection Type: Containers/WSL2
  • Logs:

Steps to Reproduce:

  1. verify that $DISPLAY is set in WSL2 console to :0:
echo $DISPLAY
:0
  1. run simple container in WSL2 console and check $DISPLAY is not set:
docker run --rm -it ubuntu:20.04
root@cc1f3d0e9394:/# echo $DISPLAY

  1. run simple container in WSL2 console, pass the variable and check if it set:
docker run --rm -it -e DISPLAY=$DISPLAY ubuntu:20.04
root@857029bd7eb8:/# echo $DISPLAY
:0
  1. create a simple test project in WSL2 with a devcontainer
    devcontainer.json:
{
	"name": "Display_Env_test",
	"image": "ubuntu:20.04",
	"containerEnv": {
		"DISPLAY": "${localEnv:DISPLAY}"
	}
}
  1. start devcontainer and check variable
    result:
root@88fc9d87b433:/workspaces/vscode_devcontainer_display_env# echo $DISPLAY
1

I have no idea where the 1 is coming from.
I have found this issue, which is not related, but you can see in its environment variables DISPLAY=1 is set. So it is not only a problem with my system.
I also found this issue with the exact same problem and the possible solution to set WSLENV. But I cannot find any documentation how, where or why to set it.

Full Log
[57 ms] Dev Containers 0.255.4 in VS Code 1.73.1 (6261075646f055b99068d3688932416f2346dd3b).
[56 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env
[471 ms] Start: Resolving Remote
[486 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env
[899 ms] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/home/user/projects/vscode_devcontainer_display_env' && /bin/sh
[918 ms] Start: Run in host: id -un
[1090 ms] user
[1090 ms] 
[1091 ms] Start: Run in host: cat /etc/passwd
[1093 ms] Start: Run in host: echo ~
[1094 ms] /home/user
[1094 ms] 
[1094 ms] Start: Run in host: test -x '/home/user/.vscode-remote-containers/bin/6261075646f055b99068d3688932416f2346dd3b/node'
[1095 ms] 
[1096 ms] 
[1096 ms] Start: Run in host: test -f '/home/user/.vscode-remote-containers/dist/vscode-remote-containers-server-0.255.4.js'
[1097 ms] 
[1097 ms] 
[1100 ms] userEnvProbe: loginInteractiveShell (default)
[1100 ms] userEnvProbe shell: /usr/bin/zsh
[1362 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 (x86)/VMware/VMware Workstation/bin/:/mnt/c/Program Files/Python39/Scripts/:/mnt/c/Program Files/Python39/:/mnt/c/Program Files/Python310/Scripts/:/mnt/c/Program Files/Python310/:/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 (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files (x86)/Webex/Plugins:/mnt/c/Program Files/CVArchiverAddin:/mnt/c/Program Files/UPX/:/mnt/c/Program Files (x86)/Pico Technology/PicoScope6/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/Vector CANdb++ 3.1/Exec32:/mnt/c/Users/user/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/user/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/user/AppData/Local/Programs/Git/cmd'
Container: None
[1364 ms] Setting up container for folder or workspace: /home/user/projects/vscode_devcontainer_display_env
[1372 ms] Start: Check Docker is running
[1372 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[1400 ms] Server API version: 1.41
[1401 ms] Start: Run in Host: docker volume ls -q
[1430 ms] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env --filter label=vsch.quality=stable
[1454 ms] Start: Run in Host: /home/user/.vscode-remote-containers/bin/6261075646f055b99068d3688932416f2346dd3b/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/user/projects/vscode_devcontainer_display_env --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env --log-level debug --log-format json --config /home/user/projects/vscode_devcontainer_display_env/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[1673 ms] (node:229212) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1673 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[1676 ms] @devcontainers/cli 0.20.0. Node.js v16.14.2. linux 5.15.62.1-made-by-Johnny+ x64.
[1676 ms] Start: Run: docker buildx version
[1851 ms] github.com/docker/buildx v0.9.1-docker ed00243a0ce2a0aee75311b06e32d33b44729689
[1851 ms] 
[1851 ms] Start: Resolving Remote
[1854 ms] Start: Run: git rev-parse --show-cdup
[1858 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env
[1882 ms] Start: Run: docker inspect --type container c80de9902e6a
[1905 ms] Start: Removing Existing Container
[1905 ms] Start: Run: docker rm -f c80de9902e6aaa016df4639993808bbb7432234afe23da05f6f13a01bf34af8c
[1952 ms] Start: Run: docker inspect --type image ubuntu:20.04
[1973 ms] local container features stored at: /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/node_modules/vscode-dev-containers/container-features
[1974 ms] Start: Run: tar --no-same-owner -x -f -
[2016 ms] Start: Run: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-user/container-features/0.20.0-1669205767002 --build-arg _DEV_CONTAINERS_BASE_IMAGE=ubuntu:20.04 --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-vscode_devcontainer_display_env-aea441e92bf53f3fe9c3e947abf2e5a1-features -f /tmp/devcontainercli-user/container-features/0.20.0-1669205767002/Dockerfile.extended /tmp/devcontainercli-user/empty-folder
[+] Building 1.1s (12/12) FINISHED                                              
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 441B                                       0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               0.6s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load build definition from Dockerfile.extended              0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04            0.0s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 2.01kB          0.0s
 => [dev_containers_target_stage 1/2] FROM docker.io/library/ubuntu:20.04  0.0s
 => CACHED [dev_containers_target_stage 2/2] COPY --from=dev_containers_f  0.0s
 => exporting to image                                                     0.0s
 => => exporting layers                                                    0.0s
 => => writing image sha256:a22759682494b2149922eac896034428c6e0536f9ca74  0.0s
 => => naming to docker.io/library/vsc-vscode_devcontainer_display_env-ae  0.0s
[3298 ms] Start: Run: docker -v
[3319 ms] Start: Run: docker events --format {{json .}} --filter event=start
[3321 ms] Start: Starting container
[3321 ms] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/user/projects/vscode_devcontainer_display_env,target=/workspaces/vscode_devcontainer_display_env --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env -e DISPLAY=1 --entrypoint /bin/sh vsc-vscode_devcontainer_display_env-aea441e92bf53f3fe9c3e947abf2e5a1-features -c echo Container started
Container started
[3859 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env
[3880 ms] Start: Run: docker inspect --type container 88fc9d87b433
[3900 ms] Start: Inspecting container
[3900 ms] Start: Run: docker inspect --type container 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60
[3922 ms] Start: Run in container: /bin/sh
[3924 ms] Start: Run in container: uname -m
[4057 ms] x86_64
[4057 ms] 
[4057 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[4058 ms] NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[4058 ms] 
[4059 ms] Start: Run in container: cat /etc/passwd
[4061 ms] Start: Run in container: test -f '/var/devcontainer/.patchEtcEnvironmentMarker'
[4062 ms] 
[4062 ms] 
[4062 ms] Exit code 1
[4062 ms] Start: Run in container: test ! -f '/var/devcontainer/.patchEtcEnvironmentMarker' && set -o noclobber && mkdir -p '/var/devcontainer' && { > '/var/devcontainer/.patchEtcEnvironmentMarker' ; } 2> /dev/null
[4066 ms] 
[4066 ms] 
[4066 ms] Start: Run in container: cat >> /etc/environment <<'etcEnvrionmentEOF'
[4072 ms] 
[4073 ms] 
[4073 ms] Start: Run in container: test -f '/var/devcontainer/.patchEtcProfileMarker'
[4074 ms] 
[4074 ms] 
[4074 ms] Exit code 1
[4074 ms] Start: Run in container: test ! -f '/var/devcontainer/.patchEtcProfileMarker' && set -o noclobber && mkdir -p '/var/devcontainer' && { > '/var/devcontainer/.patchEtcProfileMarker' ; } 2> /dev/null
[4075 ms] 
[4075 ms] 
[4075 ms] Start: Run in container: sed -i -E 's/((^|\s)PATH=)([^\$]*)$/\1${PATH:-\3}/g' /etc/profile || true
[4079 ms] 
[4079 ms] 
[4084 ms] Start: Run in Host: docker inspect --type container 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60
[4107 ms] Start: Run in Host: /home/user/.vscode-remote-containers/bin/6261075646f055b99068d3688932416f2346dd3b/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /home/user/projects/vscode_devcontainer_display_env --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env --container-id 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 --log-level debug --log-format json --config /home/user/projects/vscode_devcontainer_display_env/.devcontainer/devcontainer.json --mount-workspace-git-root true
[4307 ms] (node:229756) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[4307 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[4311 ms] @devcontainers/cli 0.20.0. Node.js v16.14.2. linux 5.15.62.1-made-by-Johnny+ x64.
[4311 ms] Start: Run: git rev-parse --show-cdup
[4317 ms] Start: Run: docker inspect --type container 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60
[4346 ms] Start: Run in Host: /home/user/.vscode-remote-containers/bin/6261075646f055b99068d3688932416f2346dd3b/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.255.4/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /home/user/projects/vscode_devcontainer_display_env --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env --container-id 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 --log-level debug --log-format json --config /home/user/projects/vscode_devcontainer_display_env/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root true
[4549 ms] (node:229781) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[4549 ms] (Use `node --trace-deprecation ...` to show where the warning was created)
[4553 ms] @devcontainers/cli 0.20.0. Node.js v16.14.2. linux 5.15.62.1-made-by-Johnny+ x64.
[4553 ms] Start: Run: git rev-parse --show-cdup
[4559 ms] Start: Run: docker inspect --type container 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60
[4587 ms] Start: Inspecting container
[4587 ms] Start: Run in Host: docker inspect --type container 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60
[4618 ms] Start: Run in Host: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=c160adc7-672f-47f9-bdec-c277dfa995b11669205763618 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 /bin/sh
[4620 ms] Start: Run in container: uname -m
[4736 ms] x86_64
[4736 ms] 
[4736 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[4738 ms] NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[4739 ms] 
[4739 ms] Start: Run in container: cat /etc/passwd
[4741 ms] Start: Updating configuration state
[4746 ms] Start: Setup shutdown monitor
[4747 ms] Forking shutdown monitor: c:\Users\user\.vscode\extensions\ms-vscode-remote.remote-containers-0.255.4\dist\shutdown\shutdownMonitorProcess \\.\pipe\vscode-remote-containers-783a720213e62908daf2b2b8172d84dcefb7b21c-sock singleContainer Debug c:\Users\user\AppData\Roaming\Code\logs\20221123T131537\window1\exthost\ms-vscode-remote.remote-containers 1669205765030
[5093 ms] Start: Run in container: test -d /root/.vscode-server
[5096 ms] 
[5096 ms] 
[5096 ms] Exit code 1
[5097 ms] Start: Run in container: test -d /root/.vscode-remote
[5099 ms] 
[5099 ms] 
[5099 ms] Exit code 1
[5100 ms] Start: Run in container: test ! -f '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' && set -o noclobber && mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[5104 ms] 
[5104 ms] 
[5104 ms] Start: Run in container: cat /root/.vscode-server/data/Machine/settings.json
[5106 ms] 
[5106 ms] cat: /root/.vscode-server/data/Machine/settings.json: No such file or directory
[5106 ms] Exit code 1
[5107 ms] Start: Run in container: test -d /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b
[5108 ms] 
[5108 ms] 
[5108 ms] Exit code 1
[5109 ms] Start: Run in container: test -d /vscode/vscode-server/bin/linux-x64/6261075646f055b99068d3688932416f2346dd3b
[5110 ms] 
[5110 ms] 
[5110 ms] Start: Run in container: mkdir -p '/root/.vscode-server/bin' && ln -snf '/vscode/vscode-server/bin/linux-x64/6261075646f055b99068d3688932416f2346dd3b' '/root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b'
[5114 ms] 
[5114 ms] 
[5114 ms] Start: Run in container: touch '/vscode/vscode-server/bin/linux-x64/6261075646f055b99068d3688932416f2346dd3b'
[5114 ms] Start: Launching Dev Containers helper.
[5115 ms] ssh-agent: SSH_AUTH_SOCK in container (/tmp/vscode-ssh-auth-76199b8f0deb8b10f501b1616317670964601290.sock) forwarded to local host (\\.\pipe\openssh-ssh-agent).
[5115 ms] Start: Run in Host: gpgconf --list-dir agent-extra-socket
[5118 ms] 
[5118 ms] 
[5120 ms] /run/user/1000/gnupg/S.gpg-agent.extra
[5120 ms] 
[5121 ms] Start: Run in container: gpgconf --list-dir agent-socket
[5122 ms] 
[5122 ms] /bin/sh: 12: gpgconf: not found
[5122 ms] Exit code 127
[5122 ms] Start: Run: gpgconf --list-dir agent-extra-socket
[5143 ms] findLocalWindowsExecutable: Exectuable 'gpgconf' not found on PATH 'C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Python39\Scripts\;C:\Program Files\Python39\;C:\Program Files\Python310\Scripts\;C:\Program Files\Python310\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Webex\Plugins;C:\Program Files\CVArchiverAddin;c:\Program Files\UPX\;C:\Program Files (x86)\Pico Technology\PicoScope6\;C:\Program Files\dotnet\;C:\Program Files (x86)\Vector CANdb++ 3.1\Exec32;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user\AppData\Local\Programs\Git\cmd'.
[5147 ms] Start: Run in Host: docker exec -i -u root 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 /bin/sh
[5147 ms] userEnvProbe: loginInteractiveShell (default)
[5148 ms] userEnvProbe shell: /bin/bash
[5151 ms] Start: Run in container: echo ~
[5152 ms] Start: Run in container: # Test for /root/.ssh/known_hosts and ssh
[5154 ms] ssh not found
[5154 ms] 
[5154 ms] Exit code 1
[5155 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --system --replace-all credential.helper '!f() { /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b/node /tmp/vscode-remote-containers-76199b8f0deb8b10f501b1616317670964601290.js $*; }; f' || true
[5156 ms] 
[5156 ms] 
[5157 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd ; readlink /proc/$pid/ns/mnt ; cat /proc/$pid/stat | tr "
[5177 ms] Start: Run in container: cat '/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b' 2>/dev/null || (umask 377 && echo '153ff3a3-48cb-4ef6-9f2a-fbca39bdaaaa' >'/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b-f9530e7c-20c4-4a0e-94e5-7d9adb7eb8fa' && mv -n '/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b-f9530e7c-20c4-4a0e-94e5-7d9adb7eb8fa' '/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b' && rm -f '/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b-f9530e7c-20c4-4a0e-94e5-7d9adb7eb8fa' && cat '/root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b')
[5183 ms] 153ff3a3-48cb-4ef6-9f2a-fbca39bdaaaa
[5183 ms] 
[5184 ms] Start: Starting VS Code Server
[5184 ms] Start: Preparing Extensions
[5184 ms] Start: Run in container: test ! -f '/root/.vscode-server/data/Machine/.installExtensionsMarker' && set -o noclobber && mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
[5187 ms] 
[5187 ms] 
[5189 ms] Extensions cache, install extensions: None
[5189 ms] Start: Run in container: test -d /root/.vscode-server/extensionsCache && ls /root/.vscode-server/extensionsCache || true
[5245 ms] 
[5245 ms] 
[5246 ms] Start: Run in container: test -d /vscode/vscode-server/extensionsCache && ls /vscode/vscode-server/extensionsCache || true
[5248 ms] 11728e16-fcf2-4f71-9c9c-eb43fb6a4924
2b9eb3f3-0bc6-4119-a59e-0c0cd208abc1
4884ffe9-e298-42af-9c88-320115629690
b0e24170-dca1-4f29-a110-3546c23f2900
eamodio.gitlens-13.0.2
eamodio.gitlens-13.0.3
eamodio.gitlens-13.0.4
eamodio.gitlens-13.1.0
eamodio.gitlens-13.1.1
github.vscode-pull-request-github-0.52.0
github.vscode-pull-request-github-0.54.0
github.vscode-pull-request-github-0.54.1
gruntfuggly.todo-tree-0.0.216
gruntfuggly.todo-tree-0.0.219
gruntfuggly.todo-tree-0.0.220
knisterpeter.vscode-commitizen-1.1.0
llvm-vs-code-extensions.vscode-clangd-0.1.22
llvm-vs-code-extensions.vscode-clangd-0.1.23
mechatroner.rainbow-csv-3.2.0
mechatroner.rainbow-csv-3.3.0
mesonbuild.mesonbuild-1.7.1
ms-azuretools.vscode-docker-1.22.2
ms-python.isort-2022.4.0
ms-python.isort-2022.6.0
ms-python.isort-2022.8.0
ms-python.python-2022.16.0
ms-python.python-2022.16.1
ms-python.python-2022.18.1
ms-python.python-2022.18.2
ms-python.vscode-pylance-2022.10.10
ms-python.vscode-pylance-2022.10.20
ms-python.vscode-pylance-2022.10.30
ms-python.vscode-pylance-2022.10.40
ms-python.vscode-pylance-2022.11.10
ms-python.vscode-pylance-2022.11.20
ms-python.vscode-pylance-2022.11.30
ms-toolsai.jupyter-2022.9.1202862440
ms-vscode.hexeditor-1.9.9
ms-vscode.powershell-2022.10.0
ms-vsliveshare.vsliveshare-1.0.5735
ms-vsliveshare.vsliveshare-1.0.5739
ms-vsliveshare.vsliveshare-1.0.5750
ms-vsliveshare.vsliveshare-1.0.5762
ms-vsliveshare.vsliveshare-1.0.5776
redhat.vscode-xml-0.22.0-linux-x64
serhioromano.vscode-st-1.12.11
serhioromano.vscode-st-1.12.12
serhioromano.vscode-st-1.12.13
serhioromano.vscode-st-1.12.14
[5249 ms] 
[5249 ms] Extensions cache, link in container: None
[5249 ms] Start: Run in Host: docker exec -i -u root -e SHELL=/bin/bash -e VSCODE_AGENT_FOLDER=/root/.vscode-server -w /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b/bin/code-server --log debug --force-disable-user-env --server-data-dir /root/.vscode-server --use-host-proxy --telemetry-level all --accept-server-license-terms --host 127.0.0.1 --port 0 --connection-token-file /root/.vscode-server/data/Machine/.connection-token-6261075646f055b99068d3688932416f2346dd3b --extensions-download-dir /root/.vscode-server/extensionsCache --start-server --disable-websocket-compression
[5270 ms] /root
[5270 ms] 
[5270 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-76199b8f0deb8b10f501b1616317670964601290.js' >/tmp/vscode-remote-containers-76199b8f0deb8b10f501b1616317670964601290.js
[5274 ms] 
[5274 ms] 
[5274 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-76199b8f0deb8b10f501b1616317670964601290.js' >/tmp/vscode-remote-containers-server-76199b8f0deb8b10f501b1616317670964601290.js_1669205770304
[5278 ms] 
[5278 ms] 
[5352 ms] userEnvProbe PATHs:
Probe:     '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
Container: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
[5441 ms] *
* Visual Studio Code Server
*
* By using the software, you agree to
* the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
* the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
*
[5445 ms] Server bound to 127.0.0.1:40225 (IPv4)
Extension host agent listening on 40225

[5446 ms] Start: Run in container: echo 40225 >'/root/.vscode-server/data/Machine/.devport-6261075646f055b99068d3688932416f2346dd3b'
[5448 ms] 
[5448 ms] 
[5448 ms] Port forwarding for container port 40225 starts listening on local port.
[5450 ms] Port forwarding local port 40225 to container port 40225
[5459 ms] Start: Run in container: # Test for /root/.gitconfig and git
[5461 ms] git not found
[5461 ms] 
[5461 ms] Exit code 1
[5462 ms] Port forwarding connection from 51971 > 40225 > 40225 in the container.
[5463 ms] Start: Run in Host: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=c160adc7-672f-47f9-bdec-c277dfa995b11669205763618 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b/node -e 
[5468 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global --replace-all credential.helper '!f() { /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b/node /tmp/vscode-remote-containers-76199b8f0deb8b10f501b1616317670964601290.js $*; }; f' || true
[5469 ms] 
[5470 ms] 
[5634 ms] [12:16:10] Extension host agent started.
[5637 ms] Port forwarding 51971 > 40225 > 40225 stderr: Connection established
[5687 ms] Port forwarding connection from 51972 > 40225 > 40225 in the container.
[5687 ms] Start: Run in Host: docker exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=c160adc7-672f-47f9-bdec-c277dfa995b11669205763618 88fc9d87b4331aeb78e5fcede50ca7fa72e1a419cb934396e1804ca8212e4d60 /root/.vscode-server/bin/6261075646f055b99068d3688932416f2346dd3b/node -e 
[5735 ms] [12:16:10] [127.0.0.1][fe2a652e][ManagementConnection] New connection established.
[5738 ms] [12:16:10] ComputeTargetPlatform: linux-x64
[5846 ms] Port forwarding 51972 > 40225 > 40225 stderr: Connection established
[5958 ms] [12:16:10] [127.0.0.1][935ed355][ExtensionHostConnection] New connection established.
[5966 ms] [12:16:10] [127.0.0.1][935ed355][ExtensionHostConnection] <232> Launched Extension Host Process.
[7996 ms] Start: Run in container: cat /proc/257/environ

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

@github-actions github-actions bot added the containers Issue in vscode-remote containers label Nov 23, 2022
@chrmarti
Copy link
Contributor

chrmarti commented Dec 5, 2022

We set DISPLAY=1 on the Windows side to make ssh use SSH_ASK_PASS. Maybe that makes its way to your WSL session. Is DISPLAY listed in the WSLENV environment variable on Windows? (Check by running echo $env:WSLENV in a Powershell terminal.) (Also see https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/ for more information.)

@chrmarti chrmarti self-assigned this Dec 5, 2022
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Dec 5, 2022
@JohnDoe2991
Copy link
Author

Running echo $env:WSLENV in the Powershell shows an empty variable:

PS C:\Users\user> echo $env:WSLENV
PS C:\Users\user>

Running the same command within VSCode in Windows shows this:

PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env> echo $env:WSLENV
VSCODE_CLI_REMOTE_ENV/w:ELECTRON_RUN_AS_NODE/w:
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Ubuntu-20.04\home\user\projects\vscode_devcontainer_display_env> 

echo $WSLENV in WSL2 shows an empty variable:

➜  ~ echo $WSLENV

➜  ~

And within VSCode in WSL2 shows this:

➜  vscode_devcontainer_display_env echo $WSLENV         
ELECTRON_RUN_AS_NODE/w:
➜  vscode_devcontainer_display_env

@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Dec 14, 2022
@jamesthurley
Copy link

I also consistently see this issue across multiple laptops and in all the dev containers I've set up that pass through the $DISPLAY variable.

I don't have a DISPLAY environment variable set in windows, in WSL it is :0 but in the containers it always comes through as 1.

@chris-stetter
Copy link

I am experiencing the very same issue using VSCode 1.76.0 and ms-vscode-remote.remote-containers version 0.283.0. Note that I am mounting the /tmp folder through docker-compose. Ideas?

@71
Copy link

71 commented Mar 22, 2023

I think the problem is that localEnv refers to the client environment, so in a VS Code remote session "Client -> (SSH | WSL) -> Dev Container", localEnv:DISPLAY refers to the client's config, not the SSH'd / WSL machine. This is also causing issues on my side, because I'm doing "Windows -> SSH -> Dev Container", and the dev container is attempting to use the Windows machine's HOME env variable with --bind, which doesn't work.

@thestalnakergroup
Copy link

I'm also experiencing this problem using dev containers with WSL images in vs code.

 echo $DISPLAY
172.18.16.1:0.0

@Tuntenfisch
Copy link

Tuntenfisch commented Oct 20, 2023

I'm using a WSL2-based dev container as well and as of version 1.83.1 this issue still persists. No matter what I attempt, the DISPLAY environment variable is always set to 1. Are there any plans on fixing this?

For now I've applied a workaround by using the following "postStartCommand" in my devcontainer.json:

if [[ $DISPLAY = "1" ]]; then  echo "export DISPLAY=:0" >> "~/.bashrc"; fi

@jamesthurley
Copy link

It seems you don't need to specify DISPLAY or WAYLAND_DISPLAY or XDG_RUNTIME_DIR in the containerEnv section of the devcontainer.json any more. They are set automatically.

Therefore removing "DISPLAY": "${localEnv:DISPLAY}" from containerEnv fixed this issue for me. It is now set correctly automatically.

In addition I had to remove:

    "-v",
    "/tmp/.X11-unix:/tmp/.X11-unix",

from runArgs as this is now also handled automatically, and explicitly setting it had started causing issues.

@MduPlessis-1
Copy link

Setting
"userEnvProbe": "interactiveShell"
in devcontainer.json solved the issue for me.

@rsarrazin2
Copy link

rsarrazin2 commented May 16, 2024

It seems you don't need to specify DISPLAY or WAYLAND_DISPLAY or XDG_RUNTIME_DIR in the containerEnv section of the devcontainer.json any more. They are set automatically.

This is correct in a WSL2 environment, but doesn't work in devcontainers run on native Linux setups where DISPLAY has to be passed into the devcontainer as in the original post.

"postStartCommand": "if [ $DISPLAY = '1' ]; then echo 'export DISPLAY=:0' >> '~/.bashrc'; fi"

I ended up using this workaround. Note the different quote signs and the sh-compatible string comparison compared to #7565 (comment).

@chrmarti chrmarti added this to the May 2024 milestone May 16, 2024
@chrmarti
Copy link
Contributor

There is a fix in Dev Containers 0.366.0-pre-release. Could everyone seeing this issue give that a try and let me know if there are any remaining issues? Thanks!

@rsarrazin2
Copy link

rsarrazin2 commented May 17, 2024

There is a fix in Dev Containers 0.366.0-pre-release. Could everyone seeing this issue give that a try and let me know if there are any remaining issues? Thanks!

I can confirm the issue is gone in the WSL2 setup (obviously after reloading the window and rebuilding the container). Even without

"containerEnv": {
    "DISPLAY": "${localEnv:DISPLAY}"
}

DISPLAY is correctly set to :0 like outside of the container.

On a native Linux, the snippet above is still required, though, but now setting the right value (while it would e.g. set :0 before instead of :1).

So in short: With the snippet above and the pre-release version, everything works as expected on both WSL2 and native Linux setups using the very same devcontainer.json.

@chrmarti
Copy link
Contributor

@rsarrazin2 The reason the Dev Containers extension sets DISPLAY inside the container to something else is that it listens on that display's socket path inside the container and forwards all connections to it to the actual display socket on the host (WSL or local).

Are you mounting /tmp in the container or why would :0 work?

@rsarrazin2
Copy link

@rsarrazin2 The reason the Dev Containers extension sets DISPLAY inside the container to something else is that it listens on that display's socket path inside the container and forwards all connections to it to the actual display socket on the host (WSL or local).

Are you mounting /tmp in the container or why would :0 work?

@chrmarti: No mounting /tmp here (see devcontainer.json snippet below). I don't know why :0 works, but that's what's set outside of the container, and my GUI apps work only with :0 set inside the container as well.

    "containerEnv": {
        "DISPLAY": "${localEnv:DISPLAY}"
    },
    "remoteUser": "vscode",
    "runArgs": [
        "--network=host"
    ],
    "mounts": [
        // Make bash history persistent (by mapping the local history to the container's remote user's).
        "type=bind,source=${localEnv:HOME}/.bash_history,target=/home/vscode/.bash_history",
        // Make SSH keys available to the vscode user
        "type=bind,source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh",
        // Make local home folder available in the container under its original path (and not as the remote
        // user's home folder).
        // This can be useful for example to enable git worktrees in the container (as the paths to the
        // worktree master are set as absolute paths).
        "type=bind,source=${localEnv:HOME}/,target=${localEnv:HOME}/"
    ]

@chrmarti
Copy link
Contributor

@rsarrazin2 What do you get for ls -l /tmp/.X11-unix/ in the container and docker inspect <container id> on localhost?

@rsarrazin2
Copy link

@chrmarti I created an MVP at https://github.com/rsarrazin2/devcontainer_for_vscode_remote_extension. Here is what I get inside the container:

$ ls -l /tmp/.X11-unix/
total 0
srwxrwxrwx 1 rolands rolands 0 May 22 09:39 X0

And outside: See docker inspection report mvp.json.

@chrmarti
Copy link
Contributor

@rsarrazin2 Could you also append the Dev Containers log from right after reopening the folder in the container? (F1 > Dev Containers: Show Container Log)

The /tmp/.X11-unix/X0 is likely from the Dev Containers extension, the log might tell us more. The extension should also set DISPLAY to :0 when you omit DISPLAY from "containerEnv". When you reload the VS Code window, it will increase the display number, but it should still work.

@rsarrazin2
Copy link

@chrmarti here you are: container.log.

I just want to clarify in case there's a misunderstanding on my side: The reports I provide are from the WSL setup where the "DISPLAY": "${localEnv:DISPLAY}" statement in the devcontainer.json doesn't make a difference (in both cases I get the host's :0). Was I supposed to send the reports from the native Linux setup where the statement is required?

@chrmarti
Copy link
Contributor

@rsarrazin2 The setup where the statement is required would be the most interesting. Could you send the information from that too? Thanks.

@rsarrazin2
Copy link

@rsarrazin2 The setup where the statement is required would be the most interesting. Could you send the information from that too? Thanks.

@chrmarti The native-Linux-setup colleagues are currently on leave and I don't have such a setup locally. I'll come back with more information in the course of this week. Thanks for your patience!

@chrmarti chrmarti modified the milestones: May 2024, June 2024 May 28, 2024
@rsarrazin2
Copy link

rsarrazin2 commented May 28, 2024

@chrmarti I got the feedback from the native Linux colleagues who gave the MVP a try with the pre-release version.

  • Without the statement, /tmp/.X11-unix/ lists X0.
  • With the statement, /tmp/.X11-unix/ lists X0 and X1.
  • In both cases, $DISPLAY is correctly set to :1.

So everything actually looks good in my opinion. Maybe we hadn't correctly reloaded and/or rebuilt the container on our various tries and mistakenly thought the statement was required in the native Linux. Thank you for your patience, and I hope you didn't waste too much time digging into the issue although it seems the latest extension revision actually solved it.

@chrmarti
Copy link
Contributor

Great, thanks!

@chrmarti chrmarti added the verified Verification succeeded label May 29, 2024
@chrmarti chrmarti modified the milestones: June 2024, May 2024 May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

9 participants