Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Subshell command in build options not executed

Open
#877 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
docker, shell, typescript
Domain
cli, devops

Research direction

Start by reproducing the issue with the devcontainer.json build.options example and the emptytestscript.sh case, then compare the generated command in devContainersSpecCLI.js with the same command run in a terminal. Trace how build options are passed to docker buildx; done means command substitution and backtick-based options behave as expected and the build accepts the resulting arguments.

Written by the indexing model from the issue text.

Description

feature-request

I have devcontainer.json setup like this

"build": {
        "dockerfile": "${localWorkspaceFolder}/docker/development/Dockerfile",
        "context": "${localWorkspaceFolder}",
        "options": [
            "$(awk '{ sub (\"\\\\\\\\$\", \" \"); printf \" --build-arg %s\", $0  } END { print \"\"  }' ${localWorkspaceFolder}/.env)"
        ]
},

awk command in options should read specified .env file and create --build-arg for every one of them.

Unfortunately when i run build command i get this error.

[3829 ms] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-rijad/container-features/0.65.0-1724398400319/Dockerfile-with-features -t vsc-asx-ubuntu-627ff9ecdd16cefae9d376770411bccfd81a6bb640f586cfb01f9d12f1afe637 --target dev_containers_target_stage --no-cache --pull $(awk '{ sub ("\\\\$", " "); printf " --build-arg %s", $0  } END { print ""  }' /home/rijad/asx-ubuntu/.env) --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/rijad/asx-ubuntu

ERROR: "docker buildx build" requires exactly 1 argument.
See 'docker buildx build --help'.

Usage:  docker buildx build [OPTIONS] PATH | URL | -
Start a build
[3861 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-rijad/container-features/0.65.0-1724398400319/Dockerfile-with-features -t vsc-asx-ubuntu-627ff9ecdd16cefae9d376770411bccfd81a6bb640f586cfb01f9d12f1afe637 --target dev_containers_target_stage --no-cache --pull $(awk '{ sub ("\\\\$", " "); printf " --build-arg %s", $0  } END { print ""  }' /home/rijad/asx-ubuntu/.env) --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/rijad/asx-ubuntu
[3861 ms]     at mtA (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:466:1933)
[3861 ms]     at async Pm (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:1856)
[3861 ms]     at async NH (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:465:610)
[3861 ms]     at async KtA (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:482:3771)
[3861 ms]     at async eB (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:482:4886)
[3861 ms]     at async hrA (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:663:200)
[3861 ms]     at async lrA (/home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js:662:13452)
[3864 ms] Exit code 1
[3867 ms] Command failed: /home/rijad/.vscode-server/bin/5437499feb04f7a586f677b155b039bc2b3669eb/node /home/rijad/.vscode-remote-containers/dist/dev-containers-cli-0.380.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-21dbc736-475c-42b1-9342-59f47582801d1724398396161 --workspace-folder /home/rijad/asx-ubuntu --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu\home\rijad\asx-ubuntu --id-label devcontainer.config_file=/home/rijad/asx-ubuntu/.devcontainer/asx/devcontainer.json --log-level debug --log-format json --config /home/rijad/asx-ubuntu/.devcontainer/asx/devcontainer.json --default-user-env-probe loginInteractiveShell --build-no-cache --remove-existing-container --mount type=volume,source=vscode,target=/vscode,external=true --mount type=bind,source=/mnt/wslg/runtime-dir/wayland-0,target=/tmp/vscode-wayland-476063ef-ff4c-4372-bf8d-ee68a591f2b0.sock --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root --include-configuration --include-merged-configuration
[3867 ms] Exit code 1

But if I take command

docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-rijad/container-features/0.65.0-1724398400319/Dockerfile-with-features -t vsc-asx-ubuntu-627ff9ecdd16cefae9d376770411bccfd81a6bb640f586cfb01f9d12f1afe637 --target dev_containers_target_stage --no-cache --pull $(awk '{ sub ("\\\\$", " "); printf " --build-arg %s", $0 } END { print "" }' /home/rijad/asx-ubuntu/.env) --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label /home/rijad/asx-ubuntu
and paste it in my terminal, it runs with no issue.

Also other ways of spawning subshell, like backticks do not work as well.

Even if i create empty test script with exec permissions and try

"options": [
    "$(${localWorkspaceFolder}/emptytestscript.sh)"
]

it ends up with same error.

I am running wsl Ubuntu on windows 10.

Dominant language
TypeScript
Stars
3k
Forks
461
Avg merge
18m
Merged PRs (30d)
5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from devcontainers/cli

All issues in devcontainers/cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.