devcontainers / devcontainers/features

Failing to mount directories sourced through localEnv

Open
#551 2 comments 1 reaction 1 assignee Claimed by @alexander-smolyakov View on GitHub
Dominant language
Shell
Stars
1.5k
Forks
621
Avg merge
2d 11h
Merged PRs (30d)
4

Description

Hello 👋,
I'm encountering difficulties on mounting directories while relying on `localEnv` variables expansion.
I've produced a minimal example based on [the documentation's example](https://code.visualstudio.com/remote/advancedcontainers/add-local-file-mount).
I've made a folder with just the `.devcontainer/devcontainer.json` file, with the following content:
```json
{
"name": "Go Dev Env",
"image": "golang:1.20.4",

"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE},target=/host-home-folder,type=bind,consistency=cached"
]
}
```

My environment is:
- Win10 19045
- VSCode 1.78.2
- Remote Development v0.24.0
- Dev Containers v0.292.0
- WSL 1.2.5.0
- Docker 20.10.12
- Ubuntu-20.04 image

This is the produced log:
```
[2023-05-18T17:37:12.972Z] Dev Containers 0.292.0 in VS Code 1.78.2 (b3e4e68a0bc097f0ae7907b217c1119af9e03435).
[2023-05-18T17:37:12.972Z] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:13.264Z] Stop (292 ms): Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:13.278Z] Start: Resolving Remote
[2023-05-18T17:37:13.294Z] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:13.582Z] Stop (288 ms): Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:13.584Z] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/home/al32/workspaces/mounttest' && /bin/sh
[2023-05-18T17:37:13.629Z] Start: Run in host: id -un
[2023-05-18T17:37:13.731Z] al32
[2023-05-18T17:37:13.732Z]
[2023-05-18T17:37:13.732Z] Stop (103 ms): Run in host: id -un
[2023-05-18T17:37:13.732Z] Start: Run in host: cat /etc/passwd
[2023-05-18T17:37:13.733Z] Stop (1 ms): Run in host: cat /etc/passwd
[2023-05-18T17:37:13.734Z] Start: Run in host: echo ~
[2023-05-18T17:37:13.735Z] /home/al32
[2023-05-18T17:37:13.735Z]
[2023-05-18T17:37:13.735Z] Stop (1 ms): Run in host: echo ~
[2023-05-18T17:37:13.735Z] Start: Run in host: test -x '/home/al32/.vscode-remote-containers/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node'
[2023-05-18T17:37:13.736Z]
[2023-05-18T17:37:13.736Z]
[2023-05-18T17:37:13.736Z] Exit code 1
[2023-05-18T17:37:13.736Z] Stop (1 ms): Run in host: test -x '/home/al32/.vscode-remote-containers/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node'
[2023-05-18T17:37:13.737Z] Start: Run in host: test -x '/home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node'
[2023-05-18T17:37:13.738Z]
[2023-05-18T17:37:13.738Z]
[2023-05-18T17:37:13.738Z] Stop (1 ms): Run in host: test -x '/home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node'
[2023-05-18T17:37:13.738Z] Start: Run in host: test -f '/home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node_modules/node-pty/package.json'
[2023-05-18T17:37:13.739Z]
[2023-05-18T17:37:13.739Z]
[2023-05-18T17:37:13.739Z] Stop (1 ms): Run in host: test -f '/home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node_modules/node-pty/package.json'
[2023-05-18T17:37:13.739Z] Start: Run in host: test -f '/home/al32/.vscode-remote-containers/dist/vscode-remote-containers-server-0.292.0.js'
[2023-05-18T17:37:13.740Z]
[2023-05-18T17:37:13.740Z]
[2023-05-18T17:37:13.740Z] Stop (1 ms): Run in host: test -f '/home/al32/.vscode-remote-containers/dist/vscode-remote-containers-server-0.292.0.js'
[2023-05-18T17:37:13.742Z] userEnvProbe: loginInteractiveShell (default)
[2023-05-18T17:37:13.742Z] userEnvProbe: not found in cache
[2023-05-18T17:37:13.743Z] userEnvProbe shell: /bin/bash
[2023-05-18T17:37:15.747Z] Start: Run in Host: /bin/sh
[2023-05-18T17:37:15.750Z] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[2023-05-18T17:37:18.448Z] Stop (2698 ms): Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[2023-05-18T17:37:18.457Z] userEnvProbe is taking longer than 2 seconds. Process tree:
13711: /bin/bash -lic echo -n 25e78cf8-1e70-4366-be69-dd314fc0da09; cat /proc/self/environ; echo -n 25e78cf8-1e70-4366-be69-dd314fc0da09
13730: sudo ip link set dev eth0 mtu 1392
[2023-05-18T17:37:18.458Z] Stop (2711 ms): Run in Host: /bin/sh
[2023-05-18T17:37:23.746Z] userEnvProbe is taking longer than 10 seconds. Avoid waiting for user input in your shell's startup scripts. Continuing.
[2023-05-18T17:37:23.748Z] Setting up container for folder or workspace: /home/al32/workspaces/mounttest
[2023-05-18T17:37:23.760Z] Start: Check Docker is running
[2023-05-18T17:37:23.760Z] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[2023-05-18T17:37:23.807Z] Stop (47 ms): Run in Host: docker version --format {{.Server.APIVersion}}
[2023-05-18T17:37:23.807Z] Server API version: 1.41
[2023-05-18T17:37:23.807Z] Stop (47 ms): Check Docker is running
[2023-05-18T17:37:23.808Z] Start: Run in Host: docker volume ls -q
[2023-05-18T17:37:23.841Z] Stop (33 ms): Run in Host: docker volume ls -q
[2023-05-18T17:37:23.847Z] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=vsch.quality=stable
[2023-05-18T17:37:23.881Z] Stop (34 ms): Run in Host: docker ps -q -a --filter label=vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=vsch.quality=stable
[2023-05-18T17:37:23.882Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:23.915Z] Stop (33 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:23.915Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:23.950Z] Stop (35 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:23.950Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:23.987Z] Stop (37 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:37:23.992Z] Start: Run in Host: /home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /home/al32/workspaces/mounttest --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --id-label devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2023-05-18T17:37:24.169Z] @devcontainers/cli 0.40.0. Node.js v16.17.1. linux 5.15.90.1-microsoft-standard-WSL2 x64.
[2023-05-18T17:37:24.169Z] Start: Run: git rev-parse --show-cdup
[2023-05-18T17:37:24.177Z] Stop (8 ms): Run: git rev-parse --show-cdup
[2023-05-18T17:37:24.179Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:24.212Z] Stop (33 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:24.218Z] Stop (226 ms): Run in Host: /home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /home/al32/workspaces/mounttest --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --id-label devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2023-05-18T17:37:24.221Z] Start: Run in Host: /home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-83b85ad4-8652-4db5-a52f-9b3a2f3a3c7a1684431432152 --workspace-folder /home/al32/workspaces/mounttest --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --id-label devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-05-18T17:37:24.396Z] @devcontainers/cli 0.40.0. Node.js v16.17.1. linux 5.15.90.1-microsoft-standard-WSL2 x64.
[2023-05-18T17:37:24.396Z] Start: Run: docker buildx version
[2023-05-18T17:37:24.480Z] Stop (84 ms): Run: docker buildx version
[2023-05-18T17:37:24.480Z] github.com/docker/buildx v0.7.1-docker 05846896d149da05f3d6fd1e7770da187b52a247
[2023-05-18T17:37:24.481Z]
[2023-05-18T17:37:24.481Z] Start: Resolving Remote
[2023-05-18T17:37:24.484Z] Start: Run: git rev-parse --show-cdup
[2023-05-18T17:37:24.488Z] Stop (4 ms): Run: git rev-parse --show-cdup
[2023-05-18T17:37:24.489Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:24.522Z] Stop (33 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:24.523Z] Start: Run: docker inspect --type image golang:1.20.4
[2023-05-18T17:37:24.556Z] Stop (33 ms): Run: docker inspect --type image golang:1.20.4
[2023-05-18T17:37:26.659Z] local container features stored at: /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/node_modules/vscode-dev-containers/container-features
[2023-05-18T17:37:26.661Z] Start: Run: tar --no-same-owner -x -f -
[2023-05-18T17:37:26.675Z] Stop (14 ms): Run: tar --no-same-owner -x -f -
[2023-05-18T17:37:26.679Z] Start: Run: docker -v
[2023-05-18T17:37:26.711Z] Stop (32 ms): Run: docker -v
[2023-05-18T17:37:26.711Z] Start: Run: docker events --format {{json .}} --filter event=start
[2023-05-18T17:37:26.714Z] Start: Starting container
[2023-05-18T17:37:26.715Z] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/al32/workspaces/mounttest,target=/workspaces/mounttest --mount source=,target=/host-home-folder,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest -l devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"mounts":["source=${localEnv:HOME}${localEnv:USERPROFILE},target=/host-home-folder,type=bind,consistency=cached"]}] golang:1.20.4 -c echo Container started
[2023-05-18T17:37:26.749Z] docker: Error response from daemon: invalid mount config for type "bind": field Source must not be empty.
See 'docker run --help'.
[2023-05-18T17:37:26.752Z] Stop (37 ms): Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/al32/workspaces/mounttest,target=/workspaces/mounttest --mount source=,target=/host-home-folder,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest -l devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"mounts":["source=${localEnv:HOME}${localEnv:USERPROFILE},target=/host-home-folder,type=bind,consistency=cached"]}] golang:1.20.4 -c echo Container started
[2023-05-18T17:37:26.753Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:26.758Z] Stop (47 ms): Run: docker events --format {{json .}} --filter event=start
[2023-05-18T17:37:26.793Z] Stop (40 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --filter label=devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json
[2023-05-18T17:37:26.795Z] Error: Command failed: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/home/al32/workspaces/mounttest,target=/workspaces/mounttest --mount source=,target=/host-home-folder,type=bind,consistency=cached --mount type=volume,src=vscode,dst=/vscode -l devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest -l devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --entrypoint /bin/sh -l devcontainer.metadata=[{"mounts":["source=${localEnv:HOME}${localEnv:USERPROFILE},target=/host-home-folder,type=bind,consistency=cached"]}] golang:1.20.4 -c echo Container started
[2023-05-18T17:37:26.795Z] trap "exit 0" 15
[2023-05-18T17:37:26.795Z] exec "$@"
[2023-05-18T17:37:26.795Z] while sleep 1 & wait $!; do :; done -
[2023-05-18T17:37:26.795Z] at Tse (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:1946:3264)
[2023-05-18T17:37:26.795Z] at rO (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:1946:3200)
[2023-05-18T17:37:26.796Z] at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2023-05-18T17:37:26.796Z] at async Xse (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:1961:2626)
[2023-05-18T17:37:26.796Z] at async vh (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:1961:3741)
[2023-05-18T17:37:26.796Z] at async gae (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:2092:10213)
[2023-05-18T17:37:26.796Z] at async mae (/home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js:2092:9954)
[2023-05-18T17:37:26.800Z] Stop (2579 ms): Run in Host: /home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-83b85ad4-8652-4db5-a52f-9b3a2f3a3c7a1684431432152 --workspace-folder /home/al32/workspaces/mounttest --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --id-label devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-05-18T17:37:26.800Z] Exit code 1
[2023-05-18T17:37:26.803Z] Command failed: /home/al32/.vscode-server/bin/b3e4e68a0bc097f0ae7907b217c1119af9e03435/node /home/al32/.vscode-remote-containers/dist/dev-containers-cli-0.292.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-83b85ad4-8652-4db5-a52f-9b3a2f3a3c7a1684431432152 --workspace-folder /home/al32/workspaces/mounttest --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest --id-label devcontainer.config_file=/home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --log-level debug --log-format json --config /home/al32/workspaces/mounttest/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[2023-05-18T17:37:26.803Z] Exit code 1
[2023-05-18T17:45:34.751Z] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
[2023-05-18T17:45:35.029Z] Stop (278 ms): Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\al32\workspaces\mounttest
```

From my understanding, `$HOME` is not expanded:
```[2023-05-18T17:37:26.749Z] docker: Error response from daemon: invalid mount config for type "bind": field Source must not be empty.```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.