fix(main): enhance PATH when spawning thv so macOS credential helpers resolve#2100
Merged
fix(main): enhance PATH when spawning thv so macOS credential helpers resolve#2100
Conversation
Collaborator
Author
|
/build-test |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes macOS GUI-launch PATH issues by ensuring the thv serve child process is spawned with an augmented PATH, allowing Docker credential helpers (e.g., docker-credential-osxkeychain) to be found when Studio is launched from Finder/Dock.
Changes:
- Extracts PATH enhancement logic into
main/src/utils/enhanced-path.tsand reuses it fromcontainer-engine.ts. - Updates
startToolhive()to spawnthv servewithPATH: createEnhancedPath()in the child environment. - Adds unit tests for the shared PATH util and a spawn-env assertion in
toolhive-managertests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| main/src/utils/enhanced-path.ts | Adds shared helper to prepend common container-tooling directories to PATH. |
| main/src/utils/tests/enhanced-path.test.ts | Tests PATH enhancement behavior across darwin/linux/win32, including ~ expansion and separators. |
| main/src/toolhive-manager.ts | Applies enhanced PATH when spawning thv serve to fix macOS credential-helper resolution. |
| main/src/tests/toolhive-manager.test.ts | Adds a test asserting spawn receives an env with an enhanced PATH. |
| main/src/container-engine.ts | Refactors to import the shared PATH enhancement helper. |
Contributor
Build Artifacts for PR #2100
Download artifacts from workflow run Version:
|
peppescg
approved these changes
Apr 24, 2026
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.
On macOS, installing a skill from the registry fails with:
The error only reproduces when Studio is launched from the Dock / Finder / Spotlight — launching
thvfrom a terminal works fine.Root cause
GUI-launched apps on macOS inherit a minimal PATH from
launchd(typically/usr/bin:/bin:/usr/sbin:/sbin) — shell rc files are never sourced. Docker's credential helpers live in/usr/local/bin,/opt/homebrew/bin, or/Applications/Docker.app/Contents/Resources/bin, none of which end up on that PATH.thv serveis spawned frommain/src/toolhive-manager.tswith the main process' env passed through unchanged. Whenthvreads~/.docker/config.jsonand sees"credsStore": "osxkeychain", it tries toexec("docker-credential-osxkeychain")against the inherited PATH and fails.We already had the exact helper needed for this —
createEnhancedPath— but it was private tomain/src/container-engine.tsand used only for the Docker / Podman detection check.Changes
main/src/utils/enhanced-path.ts— extractedcreateEnhancedPath(plusgetCommonPaths/expandPath) into a shared util. Behavior is identical to the previous in-container-engineimplementation: prepends the platform's common container-tooling dirs (Docker Desktop, Homebrew, Rancher Desktop) toprocess.env.PATH, with~expansion and the right separator per OS.main/src/container-engine.ts— drops the local copy and imports from the shared module. Pure refactor.main/src/toolhive-manager.ts— thethv servespawn now setsPATH: createEnhancedPath()inenvalongsideTOOLHIVE_SKIP_DESKTOP_CHECK. This fixes the credential-helper exec and also covers any other subprocessthvmay shell out to in the future.Tests
main/src/utils/__tests__/enhanced-path.test.ts— covers darwin / linux / win32 prepends,~expansion, existing PATH preservation, win32;separator, empty-PATH handling.main/src/tests/toolhive-manager.test.ts— new case assertingspawnis called with anenv.PATHcontaining the darwin helper dirs, while still propagatingTOOLHIVE_SKIP_DESKTOP_CHECK=true.pnpm test:nonInteractive— 167 files, 1920 tests passing.pnpm type-check— clean.How to validate
pnpm run package) on macOS with~/.docker/config.jsonset to{ "credsStore": "osxkeychain" }..appfrom Finder (not from a terminal).agents-md. The install should succeed without thedocker-credential-osxkeychainPATH error.Out of scope
fix-path/shell-envto resolve arbitrary user-installed tools (nix, asdf, mise, exotic Homebrew prefixes). Can be added later if we hit issues with the hardcoded list.thvstderr to surface a friendlier credential-helper error in the UI.