Skip to content

Discover CLIs installed via mise, asdf, volta, bun, pnpm#27

Open
wook95 wants to merge 1 commit intoaroido:mainfrom
wook95:feat/mise-asdf-discovery
Open

Discover CLIs installed via mise, asdf, volta, bun, pnpm#27
wook95 wants to merge 1 commit intoaroido:mainfrom
wook95:feat/mise-asdf-discovery

Conversation

@wook95
Copy link
Copy Markdown
Contributor

@wook95 wook95 commented May 4, 2026

On macOS with codex installed via mise (~/.local/share/mise/installs/node/24.12.0/bin/codex, shimmed at ~/.local/share/mise/shims/codex), the menu bar showed Codex as missing even though the CLI worked fine in the terminal.

Two things were going on:

candidateExecutablePaths walks a fixed list — homebrew, /usr/local/bin, ~/.local/bin, npm-global, yarn — but nothing for mise/asdf/volta or the increasingly common bun and pnpm installs. So nothing in the static list matched.

The shell fallback then runs /bin/zsh -lc 'command -v codex', which is a login non-interactive shell. That skips .zshrc, where eval "$(mise activate zsh)" typically lives, so the lookup misses every binary mise/asdf hands out via .zshrc activation. From a GUI launch the inherited PATH is sparse (no terminal session has touched it), so this fails too. env -i /bin/zsh -lc 'command -v codex' reproduces the empty result.

The fix:

  • Add the well-known shim/bin directories of mise, asdf, volta, bun, and pnpm to the candidate list, plus enumerate ~/.local/share/mise/installs/node/<ver>/bin directly so we still resolve the binary if the shim layer is missing.
  • Try -ilc before -lc when shelling out to command -v. Interactive shells can leak prompt/MOTD output, so I take the last line on stdout that starts with / instead of trusting the whole capture.

Added three tests in TokenmonProviderDiscoveryTests. They exercise the new candidate paths, the version enumeration helper, and the empty-installs-root case. swift build and the filtered test run pass on my machine; verified end-to-end against the real mise install that was failing before.

The candidate executable list and shell fallback were both blind to
runtime version managers that put binaries outside the existing
hardcoded directories. When tokenmon launches as a GUI app, its
inherited PATH typically lacks the entries those managers add through
.zshrc, so executables installed via mise (~/.local/share/mise/installs/
node/<ver>/bin/<name> with shims at ~/.local/share/mise/shims/),
asdf (~/.asdf/shims/), volta (~/.volta/bin/), bun (~/.bun/bin/), or
pnpm (~/Library/pnpm/) were not discovered and the provider showed as
missing even though the CLI was installed.

Two fixes:

  - Add the well-known shim/bin directories of mise, asdf, volta, bun,
    and pnpm to the static candidate list, plus enumerate
    ~/.local/share/mise/installs/node/<version>/bin so we still find
    the binary when the shim is absent.

  - Try the user's shell with -ilc before -lc when falling back to
    'command -v'. Login-only shells skip .zshrc, where mise/asdf
    activation typically lives, so a GUI-launched lookup misses those
    PATH additions. Output parsing now picks the last absolute path on
    stdout to ignore MOTD or prompt banners that interactive shells
    sometimes emit.

Adds focused tests covering the new candidate paths and the version
enumeration helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant