microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.69k stars 296 forks source link

Environment variables are empty when processing devcontainer.json #8836

Open jastich opened 1 year ago

jastich commented 1 year ago

We craft a devcontainer.json which uses external environment variables (e.g., USER_GID) to pass as arguments to a Dockerfile. Our organization uses C shell for legacy reasons. The environment variables are not being sourced properly within the devcontainer.json and are being passed as empty strings to Docker. This configuration previously worked for us, but then suddenly stopped working. We are not aware of any upgrades on the remote server that would have caused this issue. We are able to reproduce with versions 1.78.x, 1.79.x, and 1.80.x of VSCode as well.

Suspect: The userEnvProbe returns "command failed" after invoking /bin/csh. See full log output below. [2023-08-11T21:08:32.818Z] Command failed: /bin/csh -lic echo -n 37e1098e-91ff-4f6a-b3be-978321f72cfd; cat /proc/self/environ; echo -n 37e1098e-91ff-4f6a-b3be-978321f72cfd

Attempted to try the /bin/csh -lic command in my own terminal. Found that csh fails if the -l flag is used in combination with other arguments. Is csh supported?

Eventually fails with the output of the Dockerfile build: [2023-08-11T21:08:39.689Z] groupadd: invalid group ID ''

After I installed insiders, I was able to "open in container" on first use. Subsequent attempts to rebuild the container failed.

On SSH remote:

Steps to Reproduce:

  1. Connect via SSH tunnel to the described environment
  2. Open a folder containing .devcontainer/devcontainer.json
  3. Attempt to reopen in container.
  4. Observe failure.

Does this issue occur when you try this locally?: N/A Does this issue occur when you try this locally and all extensions are disabled?: N/A

Our devcontainer.json:

// For format details, see https://aka.ms/devcontainer.json.
{
    // ...

    "build": {
        "dockerfile": "../Dockerfile",
        "args": {
            "CONTAINER_USER_NAME": "${localEnv:USER}",
            "CONTAINER_GROUP_NAME": "${localEnv:USER_GROUP}",
            "CONTAINER_UID": "${localEnv:USER_UID}",
            "CONTAINER_GID": "${localEnv:USER_GID}"
        }
    },

    // ...
}

Dockerfile:

FROM <redacted>/docker-mr-release/firmware/sles15-gcc7-buildpack:0.2.1

USER root

ARG CONTAINER_USER_NAME
ARG CONTAINER_GROUP_NAME
ARG CONTAINER_UID
ARG CONTAINER_GID

RUN groupadd -f -g ${CONTAINER_GID} "${CONTAINER_GROUP_NAME}" && \
    useradd --no-log-init -u "${CONTAINER_UID}" -g "${CONTAINER_GID}" -m -s /bin/bash "${CONTAINER_USER_NAME}"

USER $CONTAINER_USER_NAME

ENV GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no"

Shell output in SSH environment (within VSCode terminal):

% printenv | grep USER_
USER_GROUP=users
USER_UID=<redacted>
USER_GID=100
[2023-08-11T21:08:31.538Z] Dev Containers 0.305.0 in VS Code 1.82.0-insider (76985ae7814f7cb28e2df6f1025d279bb77cbec1).
[2023-08-11T21:08:31.538Z] Start: Resolving Remote
[2023-08-11T21:08:31.569Z] Start: Run: ssh <redacted> /bin/sh
[2023-08-11T21:08:31.603Z] Start: Run in host: id -un
[2023-08-11T21:08:32.517Z] <redacted>
[2023-08-11T21:08:32.519Z] 
[2023-08-11T21:08:32.520Z] Stop (917 ms): Run in host: id -un
[2023-08-11T21:08:32.521Z] Start: Run in host: getent passwd <redacted>
[2023-08-11T21:08:32.559Z] Stop (38 ms): Run in host: getent passwd <redacted>
[2023-08-11T21:08:32.559Z] Start: Run in host: echo ~
[2023-08-11T21:08:32.597Z] /home/<redacted>/<redacted>
[2023-08-11T21:08:32.598Z] 
[2023-08-11T21:08:32.598Z] Stop (39 ms): Run in host: echo ~
[2023-08-11T21:08:32.600Z] Start: Run in host: test -x '/home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node'
[2023-08-11T21:08:32.639Z] 
[2023-08-11T21:08:32.640Z] 
[2023-08-11T21:08:32.640Z] Stop (40 ms): Run in host: test -x '/home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node'
[2023-08-11T21:08:32.640Z] Start: Run in host: test -f '/home/<redacted>/<redacted>/.vscode-remote-containers/dist/vscode-remote-containers-server-0.305.0.js'
[2023-08-11T21:08:32.674Z] 
[2023-08-11T21:08:32.674Z] 
[2023-08-11T21:08:32.674Z] Stop (34 ms): Run in host: test -f '/home/<redacted>/<redacted>/.vscode-remote-containers/dist/vscode-remote-containers-server-0.305.0.js'
[2023-08-11T21:08:32.710Z] userEnvProbe: loginInteractiveShell (default)
[2023-08-11T21:08:32.710Z] userEnvProbe: not found in cache
[2023-08-11T21:08:32.710Z] userEnvProbe shell: /bin/csh
[2023-08-11T21:08:32.818Z] Command failed: /bin/csh -lic echo -n 37e1098e-91ff-4f6a-b3be-978321f72cfd; cat /proc/self/environ; echo -n 37e1098e-91ff-4f6a-b3be-978321f72cfd
[2023-08-11T21:08:32.854Z] Setting up container for folder or workspace: /c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:32.854Z] Host: ssh://<redacted>
[2023-08-11T21:08:32.855Z] Start: Run: wsl -l -v
[2023-08-11T21:08:33.096Z] Stop (241 ms): Run: wsl -l -v
[2023-08-11T21:08:33.097Z] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c echo ~
[2023-08-11T21:08:33.511Z] Stop (414 ms): Run: wsl -d Ubuntu-20.04 -e /bin/sh -c echo ~
[2023-08-11T21:08:33.513Z] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/home/<redacted>' && /bin/sh
[2023-08-11T21:08:33.546Z] Start: Run in host: id -un
[2023-08-11T21:08:33.761Z] <redacted>
[2023-08-11T21:08:33.762Z] 
[2023-08-11T21:08:33.762Z] Stop (216 ms): Run in host: id -un
[2023-08-11T21:08:33.762Z] Start: Run in host: getent passwd <redacted>
[2023-08-11T21:08:33.763Z] Stop (1 ms): Run in host: getent passwd <redacted>
[2023-08-11T21:08:33.763Z] Start: Run in host: echo ~
[2023-08-11T21:08:33.765Z] /home/<redacted>
[2023-08-11T21:08:33.765Z] 
[2023-08-11T21:08:33.765Z] Stop (2 ms): Run in host: echo ~
[2023-08-11T21:08:33.765Z] Start: Run in host: test -x '/home/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node'
[2023-08-11T21:08:33.767Z] 
[2023-08-11T21:08:33.767Z] 
[2023-08-11T21:08:33.767Z] Stop (2 ms): Run in host: test -x '/home/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node'
[2023-08-11T21:08:33.767Z] Start: Run in host: test -f '/home/<redacted>/.vscode-remote-containers/dist/vscode-remote-containers-server-0.305.0.js'
[2023-08-11T21:08:33.768Z] 
[2023-08-11T21:08:33.768Z] 
[2023-08-11T21:08:33.768Z] Stop (1 ms): Run in host: test -f '/home/<redacted>/.vscode-remote-containers/dist/vscode-remote-containers-server-0.305.0.js'
[2023-08-11T21:08:33.769Z] userEnvProbe: loginInteractiveShell (default)
[2023-08-11T21:08:33.770Z] userEnvProbe: not found in cache
[2023-08-11T21:08:33.770Z] userEnvProbe shell: /bin/bash
[2023-08-11T21:08:33.921Z] 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/Google/Chrome/Application:/mnt/c/Program Files (x86)/Microsoft Office/Root/Office16/:/mnt/c/Program Files/Microsoft/jdk-17.0.2.8-hotspot/bin:/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/Git/cmd:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/Graphviz/bin:/mnt/c/Program Files/TortoiseSVN/bin:/mnt/c/Program Files/dotnet/:/mnt/c/Users/<redacted>/AppData/Local/Programs/Python/Python310/Scripts/:/mnt/c/Users/<redacted>/AppData/Local/Programs/Python/Python310/:/mnt/c/Users/<redacted>/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/<redacted>/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/<redacted>/AppData/Local/Box/Box Edit/:/mnt/c/Program Files (x86)/Microsoft Office/root/Client:/snap/bin'
Container: None
[2023-08-11T21:08:34.101Z] Start: Check Docker is running
[2023-08-11T21:08:34.101Z] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[2023-08-11T21:08:34.186Z] Stop (85 ms): Run in Host: docker version --format {{.Server.APIVersion}}
[2023-08-11T21:08:34.186Z] Server API version: 1.40
[2023-08-11T21:08:34.187Z] Stop (86 ms): Check Docker is running
[2023-08-11T21:08:34.188Z] Start: Run in Host: docker volume ls -q
[2023-08-11T21:08:34.264Z] Stop (76 ms): Run in Host: docker volume ls -q
[2023-08-11T21:08:34.265Z] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=vsch.quality=insider
[2023-08-11T21:08:34.347Z] Stop (82 ms): Run in Host: docker ps -q -a --filter label=vsch.local.folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=vsch.quality=insider
[2023-08-11T21:08:34.348Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:34.426Z] Stop (78 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:34.427Z] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:34.502Z] Stop (75 ms): Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:34.577Z] Start: Run in Host: /home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node /home/<redacted>/<redacted>/.vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2023-08-11T21:08:34.778Z] @devcontainers/cli 0.50.0. Node.js v18.15.0. linux 5.3.18-22-default x64.
[2023-08-11T21:08:34.778Z] Start: Run: git rev-parse --show-cdup
[2023-08-11T21:08:34.786Z] Stop (8 ms): Run: git rev-parse --show-cdup
[2023-08-11T21:08:34.787Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:34.826Z] Stop (39 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:34.843Z] Stop (266 ms): Run in Host: /home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node /home/<redacted>/<redacted>/.vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --mount-workspace-git-root true
[2023-08-11T21:08:34.916Z] Start: Run in Host: /home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node /home/<redacted>/<redacted>/.vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-99aadc8d-373b-4f69-9ee8-89d90e65270e1691788110246 --workspace-folder /c/<redacted>/<redacted>/git-repos/<redacted> --workspace-mount-consistency cached --id-label devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --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
[2023-08-11T21:08:35.128Z] @devcontainers/cli 0.50.0. Node.js v18.15.0. linux 5.3.18-22-default x64.
[2023-08-11T21:08:35.128Z] Start: Run: docker buildx version
[2023-08-11T21:08:35.171Z] Stop (43 ms): Run: docker buildx version
[2023-08-11T21:08:35.171Z] 
[2023-08-11T21:08:35.171Z] docker: 'buildx' is not a docker command.
See 'docker --help'

[2023-08-11T21:08:35.171Z] Exit code 1
[2023-08-11T21:08:35.171Z] Start: Resolving Remote
[2023-08-11T21:08:35.175Z] Start: Run: git rev-parse --show-cdup
[2023-08-11T21:08:35.179Z] Stop (4 ms): Run: git rev-parse --show-cdup
[2023-08-11T21:08:35.282Z] Failed to fetch control manifest: getaddrinfo ENOTFOUND containers.dev
[2023-08-11T21:08:35.285Z] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:35.325Z] Stop (40 ms): Run: docker ps -q -a --filter label=devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --filter label=devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json
[2023-08-11T21:08:35.329Z] Start: Run: docker inspect --type image <redacted>/docker-mr-release/firmware/sles15-gcc7-buildpack:0.2.1
[2023-08-11T21:08:35.369Z] Stop (40 ms): Run: docker inspect --type image <redacted>/docker-mr-release/firmware/sles15-gcc7-buildpack:0.2.1
[2023-08-11T21:08:35.370Z] local container features stored at: /c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/node_modules/vscode-dev-containers/container-features
[2023-08-11T21:08:35.372Z] Start: Run: tar --no-same-owner -x -f -
[2023-08-11T21:08:35.383Z] tar: Ignoring unknown extended header keyword 'SCHILY.dev'

[2023-08-11T21:08:35.383Z] tar: Ignoring unknown extended header keyword 'SCHILY.ino'
tar: Ignoring unknown extended header keyword 'SCHILY.nlink'
tar: Ignoring unknown extended header keyword 'SCHILY.dev'
tar: Ignoring unknown extended header keyword 'SCHILY.ino'
tar: Ignoring unknown extended header keyword 'SCHILY.nlink'
tar: Ignoring unknown extended header keyword 'SCHILY.dev'
tar: Ignoring unknown extended header keyword 'SCHILY.ino'
tar: Ignoring unknown extended header keyword 'SCHILY.nlink'

[2023-08-11T21:08:35.383Z] tar: Ignoring unknown extended header keyword 'SCHILY.dev'
tar: Ignoring unknown extended header keyword 'SCHILY.ino'
tar: Ignoring unknown extended header keyword 'SCHILY.nlink'

[2023-08-11T21:08:35.384Z] tar: Ignoring unknown extended header keyword 'SCHILY.dev'
tar: Ignoring unknown extended header keyword 'SCHILY.ino'
tar: Ignoring unknown extended header keyword 'SCHILY.nlink'

[2023-08-11T21:08:35.384Z] Stop (12 ms): Run: tar --no-same-owner -x -f -
[2023-08-11T21:08:35.386Z] Start: Run: docker build -f /tmp/devcontainercli-<redacted>/container-features/0.50.0-1691788115370/Dockerfile-with-features -t vsc-<redacted>-8542114bfd7b7491415043f088b2bc2d31cea26ba3a03d10f613fd84c10d2103 --target dev_containers_target_stage --no-cache --build-arg CONTAINER_USER_NAME= --build-arg CONTAINER_GROUP_NAME= --build-arg CONTAINER_UID= --build-arg CONTAINER_GID= --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:38.013Z] Sending build context to Docker daemon  524.6kB

[2023-08-11T21:08:38.130Z] Sending build context to Docker daemon  3.743MB

[2023-08-11T21:08:38.236Z] Sending build context to Docker daemon  11.85MB

[2023-08-11T21:08:38.338Z] Sending build context to Docker daemon  25.53MB

[2023-08-11T21:08:38.371Z] Sending build context to Docker daemon  29.48MB

[2023-08-11T21:08:38.378Z] Step 1/12 : ARG _DEV_CONTAINERS_BASE_IMAGE=placeholder
Step 2/12 : FROM <redacted>/docker-mr-release/firmware/sles15-gcc7-buildpack:0.2.1 AS dev_container_auto_added_stage_label
 ---> 71eb61a60ec6
Step 3/12 : USER root
[2023-08-11T21:08:38.676Z]  ---> Running in 5647a067c8b2
[2023-08-11T21:08:38.782Z] Removing intermediate container 5647a067c8b2
 ---> b6c60efdfdc0
Step 4/12 : ARG CONTAINER_USER_NAME
[2023-08-11T21:08:38.811Z]  ---> Running in 797a23daed0a
[2023-08-11T21:08:38.913Z] Removing intermediate container 797a23daed0a
 ---> c7eb013c36d1
Step 5/12 : ARG CONTAINER_GROUP_NAME
[2023-08-11T21:08:38.931Z]  ---> Running in 0e144f75dad3
[2023-08-11T21:08:39.036Z] Removing intermediate container 0e144f75dad3
[2023-08-11T21:08:39.037Z]  ---> 13ff0d9b9491
Step 6/12 : ARG CONTAINER_UID
[2023-08-11T21:08:39.059Z]  ---> Running in de75cf9a9944
[2023-08-11T21:08:39.168Z] Removing intermediate container de75cf9a9944
 ---> 43a05b424c24
Step 7/12 : ARG CONTAINER_GID
[2023-08-11T21:08:39.224Z]  ---> Running in 67400ae0cf43
[2023-08-11T21:08:39.323Z] Removing intermediate container 67400ae0cf43
 ---> 49a813ef3268
Step 8/12 : RUN groupadd -f -g ${CONTAINER_GID} "${CONTAINER_GROUP_NAME}" &&     useradd --no-log-init -u "${CONTAINER_UID}" -g "${CONTAINER_GID}" -m -s /bin/bash "${CONTAINER_USER_NAME}"
[2023-08-11T21:08:39.373Z]  ---> Running in 98feb511f2d4
[2023-08-11T21:08:39.689Z] groupadd: invalid group ID ''
[2023-08-11T21:08:39.970Z] The command '/bin/sh -c groupadd -f -g ${CONTAINER_GID} "${CONTAINER_GROUP_NAME}" &&     useradd --no-log-init -u "${CONTAINER_UID}" -g "${CONTAINER_GID}" -m -s /bin/bash "${CONTAINER_USER_NAME}"' returned a non-zero code: 3
[2023-08-11T21:08:39.973Z] Stop (4587 ms): Run: docker build -f /tmp/devcontainercli-<redacted>/container-features/0.50.0-1691788115370/Dockerfile-with-features -t vsc-<redacted>-8542114bfd7b7491415043f088b2bc2d31cea26ba3a03d10f613fd84c10d2103 --target dev_containers_target_stage --no-cache --build-arg CONTAINER_USER_NAME= --build-arg CONTAINER_GROUP_NAME= --build-arg CONTAINER_UID= --build-arg CONTAINER_GID= --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:39.986Z] Error: Command failed: docker build -f /tmp/devcontainercli-<redacted>/container-features/0.50.0-1691788115370/Dockerfile-with-features -t vsc-<redacted>-8542114bfd7b7491415043f088b2bc2d31cea26ba3a03d10f613fd84c10d2103 --target dev_containers_target_stage --no-cache --build-arg CONTAINER_USER_NAME= --build-arg CONTAINER_GROUP_NAME= --build-arg CONTAINER_UID= --build-arg CONTAINER_GID= --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /c/<redacted>/<redacted>/git-repos/<redacted>
[2023-08-11T21:08:39.986Z]     at IAA (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:463:1698)
[2023-08-11T21:08:39.986Z]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2023-08-11T21:08:39.986Z]     at async qw (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:462:1691)
[2023-08-11T21:08:39.986Z]     at async mK (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:462:610)
[2023-08-11T21:08:39.987Z]     at async mAA (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:479:3660)
[2023-08-11T21:08:39.987Z]     at async LC (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:479:4775)
[2023-08-11T21:08:39.987Z]     at async jeA (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:611:12219)
[2023-08-11T21:08:39.987Z]     at async _eA (/c/<redacted>/<redacted>/vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js:611:11960)
[2023-08-11T21:08:39.990Z] Stop (5074 ms): Run in Host: /home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node /home/<redacted>/<redacted>/.vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-99aadc8d-373b-4f69-9ee8-89d90e65270e1691788110246 --workspace-folder /c/<redacted>/<redacted>/git-repos/<redacted> --workspace-mount-consistency cached --id-label devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --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
[2023-08-11T21:08:39.990Z] Exit code 1
[2023-08-11T21:08:39.995Z] Command failed: /home/<redacted>/<redacted>/.vscode-remote-containers/bin/76985ae7814f7cb28e2df6f1025d279bb77cbec1/node /home/<redacted>/<redacted>/.vscode-remote-containers/dist/dev-containers-cli-0.305.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-99aadc8d-373b-4f69-9ee8-89d90e65270e1691788110246 --workspace-folder /c/<redacted>/<redacted>/git-repos/<redacted> --workspace-mount-consistency cached --id-label devcontainer.local_folder=/c/<redacted>/<redacted>/git-repos/<redacted> --id-label devcontainer.config_file=/c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --log-level debug --log-format json --config /c/<redacted>/<redacted>/git-repos/<redacted>/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --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
[2023-08-11T21:08:39.995Z] Exit code 1
BitshapedRob commented 2 months ago

Any news on that? I also stumbled across this?

Variables read from a .env file. Added to the local environment variables.

% printenv | grep NODEV NODEVARIANT=20

{ "name": "devcontainer", "build": { "dockerfile": "Dockerfile", "args": { "NODEVARIANT": "${localEnv:NODEVARIANT}" [...] "initializeCommand": "export $(cat .envFile | xargs)"

My Dockerfile:

ARG NODEVARIANT FROM my.docker.repo/my-image-with-node-${NODEVARIANT}:latest

When the container starts it fails because it can't find the image because the build arg is NODEVARIANT is empty.

Error: Command failed: docker inspect --type image my.docker.repo/my-image-with-node-:latest

It would be awesome to use this approach, so that we can have the devcontainer in a more generic approach in one git repo and add it as git submodule in all our projects which may need different node versions respectively a different docker image.

The file with the variables will then be residing in the main git project.

BitshapedRob commented 1 month ago

Any news on that?

DJHig commented 3 weeks ago

This is also happening to me with tcsh. The -lic argument to tcsh throws and error since the -l cannot have other arguments. Here is the --help:

tcsh 6.22.03 (Astron) 2020-11-18 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec

-b file         batch mode, read and execute commands from `file' 
-c command      run `command' from next argument 
-d              load directory stack from `~/.cshdirs' 
-Dname[=value]  define environment variable `name' to `value' (DomainOS only) 
-e              exit on any error 
-f              start faster by ignoring the start-up file 
-F              use fork() instead of vfork() when spawning (ConvexOS only) 
-i              interactive, even when input is not from a terminal 
-l              act as a login shell, **must be the only option specified** 
-m              load the start-up file, whether or not owned by effective user 
-n file         no execute mode, just check syntax of the following `file' 
-q              accept SIGQUIT for running under a debugger 
-s              read commands from standard input 
-t              read one line from standard input 
-v              echo commands after history substitution 
-V              like -v but including commands read from the start-up file 
-x              echo commands immediately before execution 
-X              like -x but including commands read from the start-up file 
--help          print this message and exit 
--version       print the version shell variable and exit 

Is there a way to override this userEnvProbe shell? I would rather use bash anyway. Our IT forces our default to tcsh.

DJHig commented 3 weeks ago

FYI: I found and tried setting the "envUserProbe" setting to all of the other options and none work. It does not seem to affect anything, since it still uses the loginInteractiveShell, regardless to the "envUserProbe":

"userEnvProbe": "interactiveShell"

[344 ms] userEnvProbe: loginInteractiveShell (default)
[344 ms] userEnvProbe: not found in cache
[344 ms] userEnvProbe shell: /bin/tcsh
[385 ms] Error reading shell environment.
[385 ms] Command failed: /bin/tcsh -lic echo -n <...redacted...>