Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Sources/Cacheout/Models/CacheCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,19 @@ struct CacheCategory: Identifiable, Hashable {
}

private func toolExists(_ tool: String) -> Bool {
let result = shell("/usr/bin/which \(tool)")
return result != nil && !result!.isEmpty
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/which")
process.arguments = [tool]
Comment on lines +189 to +191
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Set deterministic PATH for tool existence checks

This refactor invokes /usr/bin/which without setting process.environment, so it now depends on whatever PATH the app inherited. On macOS app launches (especially from Finder), PATH commonly omits /opt/homebrew/bin and /usr/local/bin, which makes toolExists("brew")/toolExists("npm") falsely return false even when tools are installed. Because resolvedPaths immediately continues when toolExists fails, probed categories can be skipped entirely and their fallback paths are never reached. Set a controlled PATH/HOME (like shell(_:) does) before process.run() to avoid this regression.

Useful? React with πŸ‘Β / πŸ‘Ž.

process.standardOutput = FileHandle.nullDevice
process.standardError = FileHandle.nullDevice

do {
try process.run()
process.waitUntilExit()
return process.terminationStatus == 0
} catch {
return false
}
}

private func runProbe(_ command: String) -> String? {
Expand Down