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

Subshell command in build options not executed #877

Open
rijad9992 opened this issue Aug 23, 2024 · 0 comments
Open

Subshell command in build options not executed #877

rijad9992 opened this issue Aug 23, 2024 · 0 comments

Comments

@rijad9992
Copy link

rijad9992 commented Aug 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant