Bug Report: Frequent "bun: command not found" Error in OpenCode TUI
Environment
- OpenCode Version: 1.15.11
- OS: Windows 11
- Shell: PowerShell 5.1
- ECC Plugin Version: 1.8.0
- Bun Version: 1.3.14 (installed via Chocolatey)
Problem Description
When using OpenCode with ECC plugin enabled, frequent bun: command not found errors appear in the TUI interface. This occurs when:
- Starting OpenCode in a project directory
- Entering bash mode with
!
- Executing any shell command
Error Message
bun: command not found: test
Reproduction Steps
- Open PowerShell terminal
- Navigate to project directory:
cd E:\wsl\shared\workspace\kevin-project-manage
- Start OpenCode:
opencode
- Press
! to enter bash mode
- Type any command (e.g.,
echo "test")
- Error appears in TUI
Expected Behavior
No bun-related errors should appear when using pnpm/npm projects.
Actual Behavior
bun: command not found error frequently appears in TUI, even though:
- Project uses pnpm (has
pnpm-lock.yaml)
- No
bun.lockb file exists in project
- Bun is installed system-wide but not used in project
Investigation Results
1. ECC Plugin Analysis
The ECC plugin's shell.env hook detects package managers by checking lock files:
const lockfiles: Record<string, string> = {
"bun.lockb": "bun",
"pnpm-lock.yaml": "pnpm",
"yarn.lock": "yarn",
"package-lock.json": "npm",
}
Finding: The hook correctly detects no lock files in the project directory and sets PACKAGE_MANAGER to undefined.
2. OpenCode Process Analysis
- OpenCode executable contains Bun runtime strings (
bun:main, bun:vfs, bun:wrap)
- Two OpenCode processes run simultaneously:
- Main process (PID: 28112)
- Server process with
--port 24138 (PID: 42264)
- Server process spawns PowerShell child process for shell execution
3. Log Analysis
OpenCode logs (~/.local/share/opencode/log/) show:
- ECC plugin loads successfully
- Package manager detection works correctly
- No
bun: command not found error is logged
- Error only appears in TUI, not in log files
4. Environment Variables
$env:PACKAGE_MANAGER = "pnpm" # Set by user
$env:ECC_DISABLED_HOOKS = "pre:bash:auto-tmux-dev"
Root Cause Hypothesis
The error likely originates from OpenCode's internal Bun runtime rather than ECC plugin:
- OpenCode appears to be built with Bun runtime (evidenced by binary strings)
- When executing shell commands, OpenCode's Bun runtime may attempt to use
bun command
- The error occurs in TUI rendering layer, not in ECC hooks
- The error is not logged, suggesting it's a TUI/display issue
issue-attachments.zip
Suggested Fixes
For OpenCode
- Investigate why Bun runtime shows
command not found errors in TUI
- Add proper error handling for shell command execution
- Log TUI errors to log files for debugging
For ECC Plugin
- Consider adding configuration to skip bun detection entirely
- Add option to set default package manager globally
- Improve error handling in
shell.env hook
Additional Context
- Project uses pnpm with
pnpm-lock.yaml
- No
package.json in project root (monorepo structure)
- Error occurs consistently across different terminal sessions
- Error appears even when
PACKAGE_MANAGER=pnpm is set
Attachments
All attachments are packaged in issue-attachments.zip:
1. Configuration Files
- opencode-config.json - OpenCode global configuration (
~/.config/opencode/opencode.json)
- ecc-hooks.ts - ECC plugin hooks implementation (
~/.opencode/plugins/ecc-hooks.ts)
- project-opencode-config.json - Project-level OpenCode configuration (if exists)
2. Log Files
- opencode-latest.log - Latest OpenCode log file (
~/.local/share/opencode/log/)
- Shows ECC plugin loading successfully
- Shows package manager detection working correctly
- No
bun: command not found error is logged
3. Environment Information
- environment-info.md - System environment details:
- OpenCode version: 1.15.11
- Bun version: 1.3.14
- Node version: v22.15.1
- PowerShell version: 5.1.26100.8521
- Environment variables (PACKAGE_MANAGER, ECC_DISABLED_HOOKS, etc.)
- Full PATH variable
4. Project Structure
- project-structure.md - Project directory listing:
- Shows monorepo structure (backend/, frontend/)
- Shows no
package.json in project root
- Shows
.opencode/ and .claude/ directories
- Shows lock files location (frontend/pnpm-lock.yaml)
5. Key Observations from Attachments
From opencode-latest.log:
service=ecc [DEBUG] shell.env hook called - worktree=E:\wsl\shared\workspace\kevin-project-manage
checking lockfile: E:\wsl\shared\workspace\kevin-project-manage\bun.lockb -> false
checking lockfile: E:\wsl\shared\workspace\kevin-project-manage\pnpm-lock.yaml -> false
checking lockfile: E:\wsl\shared\workspace\kevin-project-manage\yarn.lock -> false
checking lockfile: E:\wsl\shared\workspace\kevin-project-manage\package-lock.json -> false
Final PACKAGE_MANAGER: not detected
From environment-info.md:
ECC_DISABLED_HOOKS=pre:bash:auto-tmux-dev
PACKAGE_MANAGER=pnpm
OPENCODE_PID=42264
OPENCODE_PROCESS_ROLE=worker
Labels: bug, bun, shell, tui, ecc-plugin
Priority: Medium
Affected Versions: OpenCode 1.15.11, ECC 1.8.0
Bug Report: Frequent "bun: command not found" Error in OpenCode TUI
Environment
Problem Description
When using OpenCode with ECC plugin enabled, frequent
bun: command not founderrors appear in the TUI interface. This occurs when:!Error Message
Reproduction Steps
cd E:\wsl\shared\workspace\kevin-project-manageopencode!to enter bash modeecho "test")Expected Behavior
No bun-related errors should appear when using pnpm/npm projects.
Actual Behavior
bun: command not founderror frequently appears in TUI, even though:pnpm-lock.yaml)bun.lockbfile exists in projectInvestigation Results
1. ECC Plugin Analysis
The ECC plugin's
shell.envhook detects package managers by checking lock files:Finding: The hook correctly detects no lock files in the project directory and sets
PACKAGE_MANAGERtoundefined.2. OpenCode Process Analysis
bun:main,bun:vfs,bun:wrap)--port 24138(PID: 42264)3. Log Analysis
OpenCode logs (
~/.local/share/opencode/log/) show:bun: command not founderror is logged4. Environment Variables
Root Cause Hypothesis
The error likely originates from OpenCode's internal Bun runtime rather than ECC plugin:
buncommandissue-attachments.zip
Suggested Fixes
For OpenCode
command not founderrors in TUIFor ECC Plugin
shell.envhookAdditional Context
pnpm-lock.yamlpackage.jsonin project root (monorepo structure)PACKAGE_MANAGER=pnpmis setAttachments
All attachments are packaged in
issue-attachments.zip:1. Configuration Files
~/.config/opencode/opencode.json)~/.opencode/plugins/ecc-hooks.ts)2. Log Files
~/.local/share/opencode/log/)bun: command not founderror is logged3. Environment Information
4. Project Structure
package.jsonin project root.opencode/and.claude/directories5. Key Observations from Attachments
From opencode-latest.log:
From environment-info.md:
Labels: bug, bun, shell, tui, ecc-plugin
Priority: Medium
Affected Versions: OpenCode 1.15.11, ECC 1.8.0