Skip to content

App becomes unresponsive when executing commands requiring sudo password #652

@delorenj

Description

@delorenj

Description

When opencode executes a command that requires a sudo password, the application becomes unresponsive and hangs indefinitely.

Root Cause

The bash tool in packages/opencode/src/tool/bash.ts spawns processes without stdin connected:

const process = Bun.spawn({
  cmd: ["bash", "-c", params.command],
  cwd: App.info().path.cwd,
  maxBuffer: MAX_OUTPUT_LENGTH,
  signal: ctx.abort,
  timeout: timeout,
  stdout: "pipe",
  stderr: "pipe",
  // stdin is not specified, defaults to null/closed
})

When a sudo command is executed, it waits for password input that can never be provided, causing the process to hang until the timeout (default 1 minute).

Expected Behavior

  • Detect commands that require sudo
  • Either:
    • Provide a clear error message explaining that sudo commands are not supported
    • Or implement a mechanism to handle password prompts safely

Steps to Reproduce

  1. Ask opencode to run any command requiring sudo (e.g., sudo apt update)
  2. The app becomes unresponsive while waiting for the password prompt that can't be answered

Proposed Solution

Add detection for sudo commands and provide appropriate error handling before execution.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions