fix: preserve user PATH in streamCommand instead of overwriting it#123
Merged
Merged
Conversation
streamCommand replaced the inherited PATH with a hardcoded list via a
{ _, new in new } merge, hiding container binaries installed outside the
standard Homebrew/system dirs (e.g. Nix). Build the child PATH from the
user's PATH plus any missing standard fallback dirs via a new pure helper
mergedExecutablePath(existing:fallback:).
Fixes Mcrich23#111
Cyb3rDudu
approved these changes
Jun 30, 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.
Summary
container-compose upnow keeps the user's inheritedPATHwhen it spawnscontainer run, so installs outside the standard Homebrew/system locations (for example Nix at/run/current-system/sw/bin/container) are found instead of failing withenv: container: No such file or directory.Why this matters
In
streamCommand(Sources/Container-Compose/Commands/ComposeUp.swift), the childPATHwas built withProcessInfo.processInfo.environment.merging(["PATH": "/usr/local/bin:..."]) { _, new in new }. The{ _, new in new }closure replaced the inheritedPATHwith the hardcoded six directories, so anycontainerbinary outside those dirs was invisible to the streamedcontainer runpath (issue #111). The fix builds the childPATHfrom the user's existingPATHand only appends standard fallback directories that are not already present, preserving custom entries.Testing
Added
mergedExecutablePath(existing:fallback:)as a pure helper inSources/Container-Compose/Helper Functions.swiftand covered it with three new cases inTests/Container-Compose-StaticTests/HelperFunctionsTests.swift(user order preserved with no duplicate fallback dirs, a custom/run/current-system/sw/binentry survives, and empty/unsetPATHfalls back to the six standard dirs). Ranswift build(succeeds) andswift test --filter HelperFunctionsTests(21 tests pass).Fixes #111