fix: locate claude binary when Lumo is launched from Finder - #46
Merged
Conversation
macOS GUI apps launched from Finder / Launchpad inherit only
`/usr/bin:/bin:/usr/sbin:/sbin` and can't see common install prefixes
like `~/.local/bin`, `/opt/homebrew/bin`, `~/.npm-global/bin`, or
nvm's per-version bin directories. `which::which("claude")` therefore
failed in release builds, which made the CLI probe fall through to the
OAuth API path and surface a misleading "Claude Code login required"
banner to any user whose `claude` binary isn't in the default PATH.
This ports ClaudeBar's `BinaryLocator` (Sources/Infrastructure/Shared/
BinaryLocator.swift) to a new `services::binary_locator` module with
the same two-tier strategy:
1. Run the user's login shell — `$SHELL -l -c 'command -v <name>'`
— so it loads `.zshrc` / `.bashrc` / `.profile` and sees the same
PATH the user has in their terminal.
2. Fall back to a hand-rolled list of common install prefixes
(`~/.local/bin`, `~/.cargo/bin`, Homebrew, Nix, npm-global, pnpm,
plus nvm / Herd's per-version `node/<v>/bin` walked with numeric
version sort).
`claude_cli_probe::fetch_usage` now calls `binary_locator::locate_binary`
instead of `which::which("claude")`.
Tests: 5 new unit tests including `locate_via_login_shell_finds_sh`
which verifies end-to-end that the login shell resolves a standard
POSIX binary.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the "Claude CLI binary not found in PATH" warning that release builds show when the user launches Lumo from Finder / Launchpad. macOS GUI apps inherit a minimal
PATH(/usr/bin:/bin:/usr/sbin:/sbin) and can't see common CLI install prefixes, sowhich::which("claude")returnedNoneand the CLI probe fell through to the OAuth API path — surfacing a misleading "Claude Code login required" banner.What changed
services::binary_locatormodule ported from ClaudeBar'sBinaryLocator.swiftwith a two-tier resolution strategy:$SHELL -l -c 'command -v <name>'so it loads.zshrc/.bashrc/.profileand exposes the full user PATH.~/.local/bin,~/.cargo/bin,~/bin,~/.nix-profile/bin, Homebrew (/opt/homebrew/bin,/usr/local/bin),~/.npm-global/bin,~/Library/pnpm, plus nvm / Herd's per-versionnode/<v>/bintrees sorted by numeric version descending.claude_cli_probe::fetch_usagenow callsbinary_locator::locate_binary("claude")instead ofwhich::which("claude").Tests
5 new unit tests in
binary_locator::tests:shell_escape_simple/shell_escape_with_quote— POSIX shell escapinghuman_sort_descends_version_like— numeric-aware sort used for nvmfind_in_common_paths_returns_none_for_gibberish— negative caselocate_via_login_shell_finds_sh— end-to-end verification that the login shell resolves a standard POSIX binaryTest plan
cargo clippy --workspace -- -D warningspassescargo test -p app --lib services::binary_locator— 5 tests passpnpm tauri build→ install from DMG → launch from Finder → Usage page should resolveclaudevia the login shell and render the gauges🤖 Generated with Claude Code