devcontainer_exec tool passes command as single string instead of parsing into args #4218

Closed
opened 2026-02-16 17:43:03 -05:00 by yindo · 2 comments
Owner

Originally created by @athal7 on GitHub (Jan 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

The devcontainer_exec tool passes the entire command string as a single executable name to the container instead of parsing it into command + arguments.

Reproduction

When using devcontainer_exec with command git status:

Command failed (exit 127):
OCI runtime exec failed: exec failed: unable to start container process: exec: "git status": executable file not found in $PATH: unknown

Even with a shell wrapper sh -c "git status":

Command failed (exit 127):  
OCI runtime exec failed: exec failed: unable to start container process: exec: "sh -c \"git status\"": executable file not found in $PATH: unknown

Root Cause

The devcontainer exec CLI expects separate positional arguments:

devcontainer exec <cmd> [args..]

But the devcontainer_exec tool appears to be passing the entire command string as a single argument to devcontainer exec.

Workaround

Use the bash tool with the devcontainer CLI directly:

devcontainer exec --workspace-folder ~/.cache/devcontainer-clones/myrepo/mybranch git status

This works correctly because bash properly parses the command into separate arguments.

Expected Behavior

The devcontainer_exec tool should either:

  1. Parse the command string into an array (split on spaces, respecting quotes)
  2. Accept the command as an array parameter
  3. Use a shell wrapper internally: sh -c "<command>"

Environment

  • OpenCode version: latest
  • devcontainer CLI: @devcontainers/cli 0.80.3
  • OS: macOS
Originally created by @athal7 on GitHub (Jan 5, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem The `devcontainer_exec` tool passes the entire command string as a single executable name to the container instead of parsing it into command + arguments. ### Reproduction When using `devcontainer_exec` with command `git status`: ``` Command failed (exit 127): OCI runtime exec failed: exec failed: unable to start container process: exec: "git status": executable file not found in $PATH: unknown ``` Even with a shell wrapper `sh -c "git status"`: ``` Command failed (exit 127): OCI runtime exec failed: exec failed: unable to start container process: exec: "sh -c \"git status\"": executable file not found in $PATH: unknown ``` ### Root Cause The `devcontainer exec` CLI expects separate positional arguments: ``` devcontainer exec <cmd> [args..] ``` But the `devcontainer_exec` tool appears to be passing the entire command string as a single argument to `devcontainer exec`. ### Workaround Use the `bash` tool with the devcontainer CLI directly: ```bash devcontainer exec --workspace-folder ~/.cache/devcontainer-clones/myrepo/mybranch git status ``` This works correctly because bash properly parses the command into separate arguments. ### Expected Behavior The `devcontainer_exec` tool should either: 1. Parse the command string into an array (split on spaces, respecting quotes) 2. Accept the command as an array parameter 3. Use a shell wrapper internally: `sh -c "<command>"` ### Environment - OpenCode version: latest - devcontainer CLI: @devcontainers/cli 0.80.3 - OS: macOS
yindo closed this issue 2026-02-16 17:43:03 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 5, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #2206: [FEATURE] add exec tool as more secure alternative to bash tool - discusses command execution and argument parsing concerns
  • #5900: Opencode doesn't work in devcontainer (M1 rosetta) - related devcontainer functionality issues
  • #4728: devcontainer: v1.0.110 failed - related devcontainer issues

The core issue here is that devcontainer_exec needs to properly parse/split the command string into separate arguments, similar to what Python's subprocess and Node.js execFile do. Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 5, 2026): This issue might be a duplicate of existing issues. Please check: - #2206: [FEATURE] add `exec` tool as more secure alternative to bash tool - discusses command execution and argument parsing concerns - #5900: Opencode doesn't work in devcontainer (M1 rosetta) - related devcontainer functionality issues - #4728: devcontainer: v1.0.110 failed - related devcontainer issues The core issue here is that `devcontainer_exec` needs to properly parse/split the command string into separate arguments, similar to what Python's subprocess and Node.js execFile do. Feel free to ignore if none of these address your specific case.
Author
Owner

@athal7 commented on GitHub (Jan 5, 2026):

Closing - this is actually a bug in the opencode-devcontainers plugin, not OpenCode itself. The plugin's buildExecArgs function passes the command as a single string instead of splitting it into separate arguments.

The fix is in the plugin at: https://github.com/athal7/opencode-devcontainers

@athal7 commented on GitHub (Jan 5, 2026): Closing - this is actually a bug in the `opencode-devcontainers` plugin, not OpenCode itself. The plugin's `buildExecArgs` function passes the command as a single string instead of splitting it into separate arguments. The fix is in the plugin at: https://github.com/athal7/opencode-devcontainers
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4218