Skip to content

Sidebar "+" button fails to launch new session — opencode not found due to stripped PATH #26

@matthewmorek

Description

@matthewmorek

Ghostree version: 0.3.18
opencode version: 1.2.16
Shell: zsh
OS: macOS


Description

Clicking the "+" icon in the sidebar to add a new session fails immediately with:

bash: line 0: exec: opencode: not found
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Ghostty failed to launch the requested command:
/usr/bin/login -flp mmorek /bin/bash --noprofile --norc -c exec -l opencode
Runtime: 47 ms
Press any key to close the window.

opencode is installed and works correctly when launched from any other terminal (Ghostty, iTerm2, Terminal.app, etc.).


Root cause

Ghostty's macOS login shell mechanism uses /bin/bash as a throwaway intermediary to exec into the target command. Critically, it passes --noprofile and --norc, which means bash starts with only the bare system PATH (typically /usr/bin:/bin:/usr/sbin:/sbin). Any PATH additions made in ~/.zshrc, ~/.zprofile, ~/.bash_profile, etc. are never sourced.

opencode's default install locations — ~/.opencode/bin, $HOME/bin, $HOME/.local/bin, or npm/bun global bin dirs — are none of them on the bare system PATH. So while opencode resolves fine in an interactive shell, it is invisible to the stripped environment Ghostree uses to launch the sidebar session.

This is not a user configuration problem. The same Ghostty-level mechanism works correctly for regular terminal windows because those launch the user's actual shell (zsh), which sources the appropriate profile files and has the full PATH. The sidebar bypasses this entirely by passing opencode as a bare command name into a profileless bash.


Steps to reproduce

  1. Install opencode via the install script or npm (default install path: ~/.opencode/bin or similar user-local directory)
  2. Verify opencode works: open any terminal and run opencode — it launches correctly
  3. Open Ghostree, click the "+" button in the sidebar
  4. Observe the error above

Expected behavior

A new opencode session launches in the context of the current worktree.

Actual behavior

The session window opens and immediately closes with opencode: not found.


Suggested fix

Ghostree should resolve the opencode binary path at launch time using the user's full login shell environment, then pass the absolute path to Ghostty's command config rather than the bare name opencode.

Alternatively, Ghostree could check common install locations (⁠~/.opencode/bin, ⁠~/.local/bin, ⁠$HOME/bin, npm/bun global prefix) at startup and warn if ⁠opencode cannot be found in any of them, rather than silently failing at session launch time.


Workaround
Symlink or copy ⁠opencode to a system PATH location:

sudo ln -s $(which opencode) /usr/local/bin/opencode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions