Skip to content

fix(cli): install-tools advice loops when PATH finds another openspec #5374

Not planned

Description

@dan-petty

Problem Description

Depends on #5355.

After #5355, devops install-tools judges openspec by the version that the command on PATH prints. _off_pin (src/devops_cli/commands/install_tools.py:372-380) adds openspec to the install list when that version is not the lock's version. It does this also when the link in the target directory is already at the pin (_at_pin, lines 364-369).

When PATH finds another openspec file before the target directory, a new install changes nothing that PATH finds. Thus:

  • Each install-tools --only-missing run does npm ci again and changes nothing.
  • install-tools --check exits 1 with the hint uv run devops install-tools --tool openspec (check_version_differs, src/devops_cli/lang/en/messages.py:418-421). That command also changes nothing.
  • devops openspec check gives the hint uv run devops install-tools --tool openspec --only-missing (version_differs at src/devops_cli/lang/en/messages.py:517-519, with missing_hint at lines 480-483).

So the advice loops: each hint names a command that does not fix the problem. The cause is the PATH order, not the install.

The merged spec scenario "An older command is replaced" (openspec/specs/tools-lock-install/spec.md:30-32) asks for this reinstall. The test test_only_missing_installs_openspec_when_the_binary_on_path_prints_another_version (tests/commands/test_install_tools.py:757-770) asserts it. Thus the defect is in the plan of #5107, not in the code of #5355.

Scope: the default devcontainer PATH (~/.local/bin first), the runner image and the Service image (the image tool directory first) do not show the problem. The #5107 case (no link in the target directory) is fixed. The loop occurs on a host where a directory with an older openspec, for example /usr/local/bin, comes before the target directory on PATH.

Related: #4363 plans to remove devops install-tools and tools.lock. If #4363 merges first, close this item as superseded.

Reproduction Steps

  1. Install the locked openspec into the target directory: uv run devops install-tools --tool openspec.
  2. Put a directory with an older openspec (for example 1.14.3) before the target directory on PATH.
  3. Run uv run devops install-tools --tool openspec --only-missing. It runs npm ci again.
  4. Run uv run devops install-tools --check --tool openspec. It exits 1 with the hint uv run devops install-tools --tool openspec.
  5. Run the hint, then run step 4 again. The result does not change.

Expected vs Actual Behavior

Expected: when the link in the target directory is at the pin but PATH finds another file first, --only-missing does not install again. --check and the gate report the PATH order: the path that PATH finds, its version, and the target directory whose link is at the pin. The hint tells the user to put the target directory first on PATH or to remove the other binary.

Actual: each --only-missing run installs again. Each hint names an install that does not change the result.

Proposed Fix

  • In _off_pin, do not add a tool whose link in the target directory is at the pin. A version problem with a link at the pin is a PATH order problem.
  • Add a message for this case to install-tools --check and to the gate. The message names the path that PATH finds, its version, the target directory and the fix (the target directory first on PATH, or remove the other binary).
  • Change the merged scenario "An older command is replaced" through an OpenSpec delta in the same change. Change its test at tests/commands/test_install_tools.py:757 in the same change.
  • Keep the fix(tools): install-tools --check passes an older openspec binary #5107 case: when the target directory has no link at the pin, --only-missing installs, as now.

Existing tool: shutil.which already gives the path that PATH finds. No new tool is necessary.

Environment Diagnostics

Logs, Traces, or Terminal Output

# From the vetting verdict of #5355 (C1 + deploy-1):
# _off_pin adds openspec when PATH resolves a binary with another version, even when the link
# in the target directory is already at the pin. Each --only-missing run does npm ci again and
# changes nothing. --check then fails with the hint `install-tools --tool openspec`.

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal keys are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #5355

Alternatives check of 2026-11-22: in-use.
The item already names this tool.
Tool: python/cpython (https://github.com/python/cpython), NOASSERTION, last activity 2026-11-22, maintained.
Reason: Searches found only the Python standard library: shutil.which already resolves which openspec PATH picks, the fact the new PATH-order message needs, but it compares no versions and changes no install plan or message.

Covers:

  • Resolves the command that PATH finds
  • Returns the full path of the matched file
  • Available in the stdlib with no new dependency

Lacks:

  • Version comparison against the lock pin
  • PATH-order message naming path, version and fix
  • Install plan that skips a target link already at the pin

Proposed design

Problem statement

After #5355, install-tools judges openspec by the version that the command on PATH prints. When PATH finds another openspec before the target directory, a new install changes nothing that PATH finds. The target link is at the pin, but _off_pin still adds openspec, so --only-missing repeats npm ci. --check and the gate print an install hint that does not fix the PATH order. The fix makes the install plan depend on the target link and reports the PATH order with the resolved path, version, target directory and fix.

Acceptance criteria

Requirement: No reinstall for a target link at the pin

devops install-tools --only-missing SHALL not install a tool when the link in the target directory is at the locked version and the command on PATH prints another version.

Scenario: A shadowed link at the pin does not install

  • WHEN the test puts an openspec link at the pin in the target directory, makes PATH resolve another openspec that prints 1.14.3, and runs devops install-tools --tool openspec --only-missing
  • THEN the command exits 0 and records no npm ci run.

Requirement: Check reports the PATH order

devops install-tools --check SHALL report a PATH-order problem when the target link is at the pin and the command on PATH prints another version.

Scenario: Check names the shadowing path

  • WHEN the test sets the target link at the pin, makes PATH resolve /usr/local/bin/openspec with version 1.14.3, and runs devops install-tools --check --tool openspec
  • THEN the command exits 1 and its message names /usr/local/bin/openspec, 1.14.3, the target directory, and the fix to put the target directory first on PATH or remove the other binary.

Requirement: Gate reports the PATH order

The OpenSpec gate SHALL report a PATH-order problem when the target link is at the pin and PATH finds another openspec.

Scenario: Gate names the shadowing path

  • WHEN the test sets the target link at the pin, makes PATH resolve another openspec that prints 1.14.3, and runs devops openspec check
  • THEN the command exits 1 and its message names the resolved path, its version, the target directory, and the fix, and it does not name an install command.

Requirement: Missing target link still installs

devops install-tools --only-missing SHALL install a tool when the target directory has no link at the locked version.

Scenario: A missing link still installs

  • WHEN the test removes the target link and runs devops install-tools --tool openspec --only-missing
  • THEN the command exits 0 and records one npm ci run.

Requirement: Spec delta replaces the reinstall scenario

The tools-lock-install spec SHALL replace the 'An older command is replaced' scenario with a PATH-order scenario that does not reinstall a link at the pin.

Scenario: OpenSpec validates the changed scenario

  • WHEN the change updates the spec delta and runs uv run openspec validate --strict
  • THEN the command exits 0.

Existing Tool Considered

The alternatives check records in-use for python/cpython (shutil.which). See the Alternatives check block in the issue body for what the tool covers and lacks. The proposal adds no new tool: it changes _off_pin, adds PATH-order messages, and updates the spec and test.

Key questions

  • Should _off_pin skip a tool when its target link is at the pin and PATH resolves another version?: Yes. _off_pin SHALL select only tools whose link in the target directory is not at the pin. A version mismatch with a link at the pin is a PATH-order problem and SHALL NOT cause an install. (best practice) [sources: src/devops_cli/commands/install_tools.py:372, src/devops_cli/commands/install_tools.py:364, openspec/specs/tools-lock-install/spec.md:30]
    • Chosen: Skip install when the target link is at the pin. The target directory already holds the locked link, so an install changes nothing that PATH finds.
    • Rejected: Keep the version mismatch in _off_pin. It repeats npm ci on each --only-missing run and does not change the PATH result.
    • Rejected: Remove the version check from --check. --check must still report the PATH-order problem and its fix.
  • Where should the install-tools --check PATH-order message live?: Add check_shadowed_at_pin to InstallMessages near check_version_differs. install_tools.py SHALL use it when _at_pin is true and the version problem comes from PATH. (best practice) [sources: src/devops_cli/lang/en/messages.py:431, src/devops_cli/commands/install_tools.py:413]
    • Chosen: New check_shadowed_at_pin message. It names the PATH order and the fix instead of an install that changes nothing.
    • Rejected: Reuse check_version_differs. Its hint names an install command that does not fix the shadowed PATH.
    • Rejected: Reuse missing_hint. The target link is present, so the missing hint is false.
  • Where should the gate PATH-order message live?: Add version_shadowed to OpenspecMessages near missing_hint. gate.py SHALL use it when the target link is at the pin and PATH finds another openspec. (best practice) [sources: src/devops_cli/lang/en/messages.py:493, src/devops_cli/openspec/gate.py:121, src/devops_cli/openspec/tool.py:136]
    • Chosen: New version_shadowed message. The gate needs a PATH-order hint and must not tell the user to install again.
    • Rejected: Reuse missing_hint. The target link is at the pin, so the binary is not missing.
    • Rejected: Reuse the install message in the gate. It couples the openspec gate to the install command module and its layering.
  • How should the check and the gate share the PATH-order facts?: Add a small helper in src/devops_cli/openspec/tool.py that returns the resolved path, printed version, target directory and locked version when the target link is at the pin. install_tools.py and gate.py SHALL both use it. (best practice) [sources: src/devops_cli/openspec/tool.py:136, src/devops_cli/openspec/gate.py:121, src/devops_cli/commands/install_tools.py:364]
    • Chosen: Shared helper in openspec/tool.py. Both callers need the same facts, and the openspec module is the lower layer.
    • Rejected: Duplicate the check in both modules. Two copies can drift and report different facts.
    • Rejected: Import install_tools from the gate. The gate would depend on a command module and can create an import cycle.
  • Does the fix(tools): install-tools --check passes an older openspec binary #5107 missing-link install remain?: Yes. When the target directory has no link at the pin, _at_pin is false, _off_pin keeps the tool, and --only-missing installs it as before. [sources: src/devops_cli/commands/install_tools.py:372, src/devops_cli/commands/install_tools.py:542, tests/commands/test_install_tools.py:757]
  • Should the merged scenario change through an OpenSpec delta?: Yes. The change SHALL replace the 'An older command is replaced' scenario with a PATH-order scenario and update its test. (best practice) [sources: openspec/specs/tools-lock-install/spec.md:30, tests/commands/test_install_tools.py:757]
    • Chosen: Replace the old scenario through a delta. The old scenario asks for the reinstall that causes the loop, so it must not stay in force.
    • Rejected: Add a new scenario and keep the old one. The two scenarios would contradict each other.
    • Rejected: Change the test only. The merged spec would still require the reinstall.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/cli
    status/new
    value/medium
    effort/medium
    on Nov 13, 2026
  2. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The need splits into finding which executable PATH actually resolves and changing the install plan and messages. shutil.which, which the issue names as the existing tool, already covers the lookup and exposes the shadowing path, but it does not change _off_pin or emit the check/gate hint. Searches found no maintained external library beyond an old whichcraft shim of the same standard-library function, so no new tool is warranted.

    The item already names this tool.

    Tool: python/cpython (https://github.com/python/cpython)

    • License: NOASSERTION
    • Last activity: 2026-11-16
    • Maintained: yes

    Covers:

    • Resolves which executable PATH finds for a command, including a binary in an earlier PATH directory that shadows the target directory
    • Gives the resolved path that the check and gate need in order to report the PATH-order problem

    Lacks:

    • Does not change _off_pin to skip installing a tool whose link in the target directory is already at the pin
    • Does not produce the install-tools --check or gate message naming the PATH-resolved path, its version, the target directory and the fix
    • Does not update the OpenSpec scenario or its test

    Tools considered:

    Searches run:

    • whichcraft PyPI package find executable PATH, results: 5
    • Python shutil.which find executable on PATH docs, results: 5
    • whichcraft python cross-platform which command, results: 5
    • shutil.which documentation Python 3, results: 5
    • whichcraft pypi, results: 5
    • python shutil which, results: 5
    • site:docs.python.org shutil.which, results: 5
    • shadowed binary PATH order detect python package, results: 5
    • whichcraft 0.6.1 python package, results: 5
    • "shutil.which" python documentation, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 2620fae (see proposed design in issue body).

  7. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor

    Closed: devops install-tools no longer exists.

    #6555 deleted the command and tools.lock. The devtools image gives the tools. The item itself says to close it when the command goes.

  8. removed
    status/ready
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/clisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions