Skip to content

fix(doctor): improve shell path resolution#742

Merged
matt2e merged 5 commits into
mainfrom
kalvin/doctor
May 28, 2026
Merged

fix(doctor): improve shell path resolution#742
matt2e merged 5 commits into
mainfrom
kalvin/doctor

Conversation

@kalvinnchau
Copy link
Copy Markdown
Contributor

Summary

  • fix doctor binary resolution to avoid treating zsh function/alias output as executable paths.
  • replace login-shell which with path-only shell lookup: whence -p for zsh and type -P for bash.
  • validate resolved candidates as absolute executable files before using them.
  • apply the same resolver hardening to shared acp-client and blox-cli command discovery.
  • simplify resolver control flow and add focused tests for invalid shell output.

i have git mapped to a function that does some cleanup, but a minimal repro:

git() {
  echo "hi"
  command git "$@"
}
image

Testing

  • cargo fmt -p doctor -p acp-client -p blox-cli
  • cargo test -p doctor -p acp-client -p blox-cli

use shell path-only lookup commands instead of plain which and validate resolved candidates as absolute executable files.

apply the same executable validation to shared cli resolvers so function or alias output cannot be treated as a binary path.
flatten login shell resolution branches and avoid an intermediate allocation when building lookup commands.

preserve executable path validation while making output summarization safe for non-ascii command output.
@wesbillman
Copy link
Copy Markdown
Collaborator

@codex please review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5eaf5c7905

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/doctor/src/resolve.rs Outdated
kalvinnchau and others added 3 commits May 27, 2026 10:06
scan login shell lookup stdout for absolute executable paths so startup messages do not hide tools installed through the user's shell path. keep relative output and shell function bodies ignored.
rc files run before -c and can emit absolute paths before the lookup builtin's answer, so iterating from the top can shadow the real result with startup output. take the last executable absolute path instead.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
add a regression test in each resolver crate that exercises the rc-file echo case: two executables on disk, both as absolute paths in stdout, decoy first. the picker should return the second one.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e merged commit b60f278 into main May 28, 2026
7 checks passed
@matt2e matt2e deleted the kalvin/doctor branch May 28, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants