Repository navigation
Description
Problem
Product code finds some tools through the installer folder of devops install-tools and not through PATH. DEFAULT_LOCAL_BIN_DIR (~/.local/bin) comes first in the search path of the review resolvers of ruff and semgrep (_default_ruff_block_checker in review/analysis.py, _resolve_semgrep_binary in review/rules_pack.py). infra/ansible_facts.py:68-80 also looks in the installer folder first. When an image or a package manager installs a tool in another folder, the lookup misses it or finds a different copy.
Owner decision of 2026-11-19: every tool comes from the devtools image (dan-petty/devtools#1) on PATH, and #4363 removes the installer.
Change
- Product code finds each tool with
shutil.whichthroughdevops_cli.core.binaries(check_binary,require_binary). When the tool is missing, it raisesDependencyErrorwith an install hint. The hint names the tool and its upstream install source (or the devtools image), notdevops install-tools. - Remove
DEFAULT_LOCAL_BIN_DIRfrom the review resolvers and the installer-folder lookup ofinfra/ansible_facts.py:68-80. - Rule: no product code calls
tool_install_dirorinstalled_commands. Remove every such call. tests/support/infra.py:101changes with it.devops install-toolskeeps its behavior until chore(tools): remove devops install-tools and tools.lock #4363 removes it.
Renovate. None.
Risk. Low. A host that has a tool only in the installer folder and not on PATH now sees the install hint.
Proof
- Unit tests with a stand-in on PATH (found) and only in
~/.local/bin(DependencyError). git grep -nE 'tool_install_dir|installed_commands|DEFAULT_LOCAL_BIN_DIR' origin/main -- srcreturns only the tools_lock package andcommands/install_tools.py.
Depends on: none
Proposed design
Problem statement
Code under src/devops_cli/review finds ruff and semgrep through the installer directory DEFAULT_LOCAL_BIN_DIR (~/.local/bin) before it looks on PATH. An image or a package manager that installs a tool in another directory is therefore missed, and the command reports the tool as missing. The change uses the existing check_binary and require_binary helpers, which call shutil.which and raise DependencyError with an install hint. Product code then finds a tool on PATH only.
Acceptance criteria
Requirement: PATH lookup
A command that needs an external tool SHALL find it on PATH through devops_cli.core.binaries.
Scenario: Tool on PATH
- WHEN A test puts a stand-in semgrep executable on PATH and ~/.local/bin holds no semgrep
- THEN The resolver of the rule-pack test runner returns the path of the stand-in.
Requirement: Installer directory is not a search path
A tool lookup MUST NOT add DEFAULT_LOCAL_BIN_DIR to the search path.
Scenario: Stand-in only in the installer directory
- WHEN A test puts a stand-in semgrep executable in ~/.local/bin and no semgrep on PATH
- THEN The resolver raises DependencyError and never returns the path of the stand-in.
Requirement: Missing tool message
A command that needs an external tool SHALL raise DependencyError through require_binary with an install hint that names the tool and its upstream install source.
Scenario: Tool absent from PATH
- WHEN PATH holds no ruff binary and a test calls _default_ruff_block_checker
- THEN The call raises DependencyError with a non-empty install_hint and a message that names ruff.
Requirement: No installer lookup in product code
Product code under src/devops_cli/security, review, k8s and research MUST NOT call tool_install_dir or installed_commands, and MUST NOT use DEFAULT_LOCAL_BIN_DIR to find a tool.
Scenario: Source scan
- WHEN A test scans the source files of the four packages for the identifiers tool_install_dir, installed_commands and DEFAULT_LOCAL_BIN_DIR
- THEN The scan reports no match.
Requirement: Install tools command unchanged
devops install-tools and its status subcommand SHALL keep their current behavior until a later item removes them.
Scenario: Install tools tests
- WHEN The tests of tests/commands/test_install_tools.py run
- THEN They pass with no change to src/devops_cli/commands/install_tools.py.
Existing Tool Considered
No alternatives check has run. The Python standard library shutil.which covers the need, and the project already wraps it: check_binary and require_binary in src/devops_cli/core/binaries.py return the path or raise DependencyError with an optional install_hint, and docs/SDLC.md requires them instead of raw shutil.which. The wrapper lacks nothing that this change needs, so the change builds no new code. It replaces two PATH-prefix lookups and adds an install hint at each call site. The cost is small: a few thousand tokens and under one hour.
Key questions
- Which product files find a tool through the installer directory or through tools.lock?: DEFAULT_LOCAL_BIN_DIR prefixes the search path in
_default_ruff_block_checker(src/devops_cli/review/analysis.py) and_resolve_semgrep_binary(src/devops_cli/review/rules_pack.py).tool_install_dirandinstalled_commandsappear only in src/devops_cli/commands/install_tools.py, src/devops_cli/tools_lock/init.py and tests/support/tools.py. The otherload_tools_lockreaders in review, k8s and research read a version pin, not a location. The security package holds no reader, and the implementer still runs thegit grepof the issue to confirm it. [sources: src/devops_cli/config/defaults.py, src/devops_cli/review/analysis.py:820, src/devops_cli/review/rules_pack.py:206, src/devops_cli/commands/install_tools.py, src/devops_cli/tools_lock/init.py, tests/support/tools.py, src/devops_cli/k8s/doctor.py, src/devops_cli/research/tool_pins.py] - Should each call site call shutil.which directly, or should one helper wrap it?: Use the existing helper
require_binary, andcheck_binaryfor a yes/no test, from devops_cli.core.binaries. It wrapsshutil.which, raisesDependencyErrorwith an install hint, and the project rule requires it instead of rawshutil.which. No new helper is written. (best practice) [sources: src/devops_cli/core/binaries.py, src/devops_cli/exceptions/tools.py, docs/SDLC.md]- Chosen: Reuse core.binaries require_binary and check_binary. The helper exists, docs/SDLC.md requires it, and it builds on the standard shutil.which.
- Rejected: Call shutil.which at each call site. docs/SDLC.md forbids raw shutil.which, and it repeats the missing-tool handling.
- Rejected: Write a new helper in each package. It duplicates core.binaries.
- What does the install hint say?: The
install_hintnames the tool and its upstream install source or a package-manager command, such as the tool's documented install page. It does not namedevops install-tools, because a later item removes that command. (best practice) [sources: src/devops_cli/exceptions/tools.py, src/devops_cli/core/binaries.py, docs/ERRORS.md:47]- Chosen: Name the tool and its upstream install source. It stays valid after the removal of devops install-tools.
- Rejected: Tell the user to run devops install-tools. The command goes away in a later item.
- Rejected: Give no install hint. The acceptance criteria require a non-empty hint, and DependencyError supports one.
- Does a missing tool raise an error, or does the check skip?: The check raises
DependencyErrorthroughrequire_binary, with the install hint. The current fallback to the bare command name hides the cause behind a subprocess failure, and a silent skip hides a missing tool. (best practice) [sources: src/devops_cli/core/binaries.py, src/devops_cli/review/analysis.py:820, src/devops_cli/exceptions/tools.py]- Chosen: Raise DependencyError with the install hint. The user learns which tool is missing and how to install it, and the error names the tool.
- Rejected: Fall back to the bare command name and let the subprocess fail. The subprocess error hides the cause, and the command does not say how to install the tool.
- Rejected: Skip the check and record a coverage gap. A silent skip hides the missing tool, and the issue asks the command to report it.
- Does this item remove every tools.lock read in product code?: No. This item removes the tool lookup through the installer directory and lock. The version-pin reads stay, and a separate item moves them. The pins are the registry of
devops install-tools, and the installer, CI and research use them. (best practice) [sources: src/devops_cli/review/rules_pack.py, src/devops_cli/review/analysis.py, src/devops_cli/k8s/doctor.py, src/devops_cli/research/tool_pins.py]- Chosen: Remove the tool lookup only. One pull request stays small, and the pins need a design of their own.
- Rejected: Remove every tools.lock read in this item. It changes the pins that the installer, CI and research use, and does not fit one pull request.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Alternatives check of 2026-11-19: not-applicable.
Class: refactor, no search.
Tool: none found.
Activity
dan-petty commentedon Nov 10, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
refactorprefix of the title gives the type.(security)scope of the title gives the scope.It is a prerequisite for removing devops install-tools and fixes tool lookup in four code areas.It removes a broken lookup path in security, review, k8s and research code.It touches four source areas and replaces a shared lookup helper with shutil.which.Both items concern tool discovery on PATH, but #4359 places tools in the image while this item changes code to look them up on PATH.devops-cli-service commentedon Nov 10, 2026
Refine cannot set this item to Ready at 273e4c9 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.
fix(devcontainer): the image gets its tools with native build steps (#…
devops-cli-service commentedon Nov 10, 2026
Status set to Ready at 84d1570 (see proposed design in issue body).
Moved to new items: #4388.
devops-cli-service commentedon Nov 11, 2026
Alternatives check: not-applicable
Class: refactor. The check makes no search and no model call for an item of this class.
Tool: none found
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
dan-petty commentedon Nov 20, 2026
Closed as not planned: replaced by #4363. Owner decision of 2026-11-20 (#4363, comment 7047909430): one pull request deletes the tools lock and every reader. The reviewed work of PR #6542 stays on its branch for reuse.
refactor(review): find tools on PATH and read installed versions
refactor(review): find tools on PATH and read installed versions
refactor(review): find tools on PATH and read installed versions