Skip to content

Bug: Codex and Gemini CLI not recognized in NVM/custom PATH environments on macOS #8

Closed

Description

@chan-yuu

Description

Termpolis fails to recognize installed AI agents like Codex and Gemini CLI in environments where binaries are managed by version managers (like NVM) or located in custom directories not covered by the current hardcoded fallbacks.

Problem Analysis

In src/main/index.ts, the findAgentInstalled function checks for binaries using:

  1. which [agent]
  2. Hardcoded paths: ~/.local/bin, /usr/local/bin, /opt/homebrew/bin (on macOS/Linux).

However, on macOS, GUI applications often do not inherit the full shell PATH (e.g., configurations from .zshrc or .bash_profile). This causes which to fail if the binary is in a path managed by NVM (e.g., ~/.nvm/versions/node/v24.15.0/bin).

Environment Context

In my specific environment:

  • Gemini CLI is installed via npm/nvm: /Users/mac/.nvm/versions/node/v24.15.0/bin/gemini
  • Codex is also present but not detected.

The current fallback paths do not include NVM-managed directories or generic global npm prefix paths.

Suggested Solutions

  1. Inherit Shell PATH: Use a library like fix-path or shell-path in the main process to ensure the Electron environment has the same PATH as the user's interactive shell.
  2. Expand Fallback Paths: Include common global npm/pnpm bin directories.
  3. Manual Configuration: Allow users to specify custom binary paths in the application settings.

Version Information

  • OS: macOS (Darwin)
  • Termpolis: Latest main branch

Activity

  1. chan-yuu commented on May 21, 2026

    @chan-yuu
    Author

    Related situation:

    Image Image
  2. codedev-david commented on May 21, 2026

    @codedev-david
    Owner

    @chan-yuu — fixed in 5b8b3f3 (will ship in the next release). Two-pronged attack:

    1. Static directory list expanded — getAgentExtraPaths() on macOS/Linux now includes Volta (~/.volta/bin), asdf (~/.asdf/shims), n (~/n/bin), yarn (~/.yarn/bin), ~/.npm-global/bin, bun (~/.bun/bin), plus dynamic enumeration of every ~/.nvm/versions/node/*/bin and $FNM_DIR/node-versions/*/installation/bin.

    2. Interactive-shell PATH discovery — new getInteractiveShellPath() forks $SHELL -ilc once at startup and captures the PATH your terminal actually sees (sources .zshrc/.bashrc, so NVM's nvm.sh, asdf's init, custom prefix overrides all get picked up). Result is cached for the process.

    Both feed into findAgentInstalled, which now passes the combined PATH as env.PATH to which/where — so even if launchd's minimal PATH is missing your NVM dir, detection still resolves it.

    Could you pull main and confirm Gemini + Codex show as installed on your machine? If anything's still missing I can iterate — easiest way to debug would be to run this in a Termpolis-launched terminal and share the output:

    ```
    echo "PATH=$PATH"
    which gemini codex
    ls -la ~/.nvm/versions/node/*/bin/gemini 2>/dev/null
    ```

    Thanks for the well-scoped report — the file-path detail made the fix straightforward.

  3. chan-yuu commented on May 21, 2026

    @chan-yuu
    Author

    Another annoying issue is that if I forget to start Termpolits, I won't be able to connect to the MCP server, and then I won't be able to use the Gemini CLI:

    Image

    and I haven't figured out how to make them compatible.

  4. codedev-david commented on May 21, 2026

    @codedev-david
    Owner

    @chan-yuu — fixed in 10985ed (degrade-gracefully patch). The adapter used to process.exit(1) the moment the token file was missing, which is exactly the state when Termpolis isn't running — Gemini saw that as a hard MCP-server-crash and blocked all CLI use.

    New behavior when Termpolis is offline:

    • initialize still returns a real handshake (host treats the server as healthy)
    • tools/list / resources/list / prompts/list return empty arrays
    • any tool call returns a friendly JSON-RPC error: "Termpolis is not running. Start Termpolis to enable its MCP tools. Other agent features should work normally."
    • if the connection drops mid-session (e.g., you close Termpolis while Gemini is up), the adapter flips into degraded mode instead of letting every subsequent call hang on a network timeout

    So from Gemini's perspective the Termpolis MCP server simply has zero tools to offer — and the rest of the CLI works as expected. No more "compatible" requirement: you can launch Gemini standalone whenever you want, and start Termpolis only when you actually want its tools.

    Will ship in the next release. Thanks again for surfacing both of these.

  5. added a commit that references this issue on May 21, 2026
  6. codedev-david commented on May 21, 2026

    @codedev-david
    Owner

    Hey @chan-yuu — thanks again for the careful report. Both pieces of your bug have shipped in v1.11.58:

    1. Codex/Gemini detection on macOS — PATH discovery now walks NVM/asdf/volta install dirs plus your interactive shell PATH, so Termpolis finds the agents wherever your shell finds them.
    2. "MCP server crashed" in Gemini CLI — the stdio adapter no longer exits when Termpolis isn't running. It now reports zero MCP tools and returns a friendly JSON-RPC error on tool calls, so the rest of Gemini CLI keeps working normally.

    If you hit anything else — anywhere in Termpolis — please open a new issue and I'll get on it right away. Really appreciate you taking the time to report this in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-notifiedOpener has been notified that a release contains the fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions