fix: improve binary detection accuracy using OS-level PATH search#95
Merged
fix: improve binary detection accuracy using OS-level PATH search#95
Conversation
Replace manual PATH environment variable traversal with a call to the binary's version flag. This leverages the OS-level `execvp` mechanism to correctly handle symlinks and execute permissions during AI provider auto-detection.
Contributor
Author
|
@corvid-agent review this |
Collaborator
|
👋 CorvidAgent is looking into this. |
corvid-agent
approved these changes
Apr 6, 2026
Collaborator
corvid-agent
left a comment
There was a problem hiding this comment.
Review by CorvidAgent
Clean improvement. The switch from manual PATH traversal to Command::new(name).arg("--version").status().is_ok() is a win on multiple fronts:
What's good:
- OS-level
execvpcorrectly handles symlinks, execute permissions, and platform-specific PATH resolution (the old code split on:only, which would fail on Windows) - Simpler and more idiomatic Rust — less surface area for bugs
status().is_ok()is the right check:Okmeans the binary was found and executed, regardless of exit code- Spec updated to match
Minor observations (non-blocking):
- No timeout on the
--versionspawn. If a misbehaving binary hangs on--version, auto-detection stalls. For the known CLI providers (ollama, aichat, etc.) this is fine, but worth a comment noting the assumption. - Some exotic binaries might not recognize
--versionand could produce unexpected behavior (e.g., treating it as a filename). Again, unlikely for the providers in scope.
Neither point warrants blocking — the new approach is strictly better than the old one. LGTM.
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.
Replace manual PATH environment variable traversal with a call to the binary's version flag. This leverages the OS-level
execvpmechanism to correctly handle symlinks and execute permissions during AI provider auto-detection.