diff options
| author | Jacob Hands <[email protected]> | 2025-07-02 22:37:48 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-02 23:37:48 -0400 |
| commit | 69920a73d79f413e361491f9fa78ed49cb58d05f (patch) | |
| tree | 8acd4282ca321dfb3a8c342b0212474ca4f991d6 /packages | |
| parent | ae76a3467afe4dfa19f2b9cf4db185ff8e845d8a (diff) | |
| download | opencode-69920a73d79f413e361491f9fa78ed49cb58d05f.tar.gz opencode-69920a73d79f413e361491f9fa78ed49cb58d05f.zip | |
fix: use correct opencode bin path when running in development mode (#483)
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/cmd/tui.ts b/packages/opencode/src/cli/cmd/tui.ts index 87f6f982e..04e90978e 100644 --- a/packages/opencode/src/cli/cmd/tui.ts +++ b/packages/opencode/src/cli/cmd/tui.ts @@ -100,7 +100,7 @@ export const TuiCommand = cmd({ UI.empty() UI.println(UI.logo(" ")) const result = await Bun.spawn({ - cmd: [process.execPath, "auth", "login"], + cmd: [...getOpencodeCommand(), "auth", "login"], cwd: process.cwd(), stdout: "inherit", stderr: "inherit", @@ -112,3 +112,25 @@ export const TuiCommand = cmd({ } }, }) + +/** + * Get the correct command to run opencode CLI + * In development: ["bun", "run", "packages/opencode/src/index.ts"] + * In production: ["/path/to/opencode"] + */ +function getOpencodeCommand(): string[] { + // Check if OPENCODE_BIN_PATH is set (used by shell wrapper scripts) + if (process.env["OPENCODE_BIN_PATH"]) { + return [process.env["OPENCODE_BIN_PATH"]] + } + + const execPath = process.execPath.toLowerCase() + + if (Installation.isDev()) { + // In development, use bun to run the TypeScript entry point + return [execPath, "run", process.argv[1]] + } + + // In production, use the current executable path + return [process.execPath] +} |
