You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: working directory incorrectly set to opencode package directory when running via bun fallback #22
When OpenCode is launched from a user's project directory and falls back to running via bun (no prebuilt binary found), the working directory gets incorrectly set to the OpenCode package directory instead of the user's project directory.
Root Cause
In packages/opencode/bin/opencode, the bun() function spawns bun with cwd: dir, where dir is the OpenCode package directory (resolved from scriptDir). This is necessary so that ./src/index.ts resolves correctly. However, it means process.cwd() in the spawned process returns the OpenCode package path, not the user's original working directory.
All CLI commands call bootstrap(process.cwd(), ...), which then passes the wrong directory to Instance.provide().
Expected Behavior
When a user runs opencode from /Users/user/my-project, the instance should be initialized with /Users/user/my-project as the working directory, regardless of whether the bun fallback path is used.
Fix
Capture the original CWD in bin/opencode before spawning bun and pass it as OPENCODE_ORIGINAL_CWD env var
Resolve the env var centrally in bootstrap() so all commands benefit
Activity
fix: preserve original CWD when bun spawns opencode subprocess (#22)
fix: restore CWD via process.chdir in index.ts instead of per-caller …
fix: preserve original CWD when bun spawns opencode subprocess (#23)
fix: resolve upstream merge typecheck error in test harness (#22)
fix: resolve upstream merge typecheck error in test harness (#22)