Skip to content

fix: detect relocated uv and pipx tool installations - #5103

Open
Shubham-Padkonde wants to merge 5 commits into
github:mainfrom
Shubham-Padkonde:fix/5095-detect-relocated-tool-installs
Open

Shubham-Padkonde wants to merge 5 commits into
github:mainfrom
Shubham-Padkonde:fix/5095-detect-relocated-tool-installs

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #5095. specify self upgrade classifies valid uv/pipx installations outside the old hard-coded folders as unsupported. Detect relocated tool environments through UV_TOOL_DIR, PIPX_HOME, XDG data locations, and platform defaults while retaining legacy paths.

The review fixes also recognize uv's current %APPDATA%/uv/tools and legacy macOS ~/Library/Application Support/uv/tools directories. Preserve variable-specific tilde handling: PIPX_HOME expands it to the home directory, UV_TOOL_DIR treats it literally under the working directory, and relative XDG_DATA_HOME values (including tilde-prefixed values) are ignored. Relative PIPX_HOME and UV_TOOL_DIR paths resolve against the working directory. Unset/empty/unresolved-variable guards, path-component boundaries, and registry fallback restrictions remain intact. Relative XDG paths are still rejected.

The upgrade guide explains that relocation variables must remain set when running the installer. Ephemeral uvx detection and copied Windows entrypoint shims outside the tool environment are outside this path-detection change.

Validation

Windows, Python 3.14.6, using this checkout's own virtualenv:

  • python -m pytest tests/specify_cli/test_version_detection.py tests/specify_cli/test_version_execution.py tests/specify_cli/test_version_guidance.py tests/specify_cli/test_version_verification.py tests/specify_cli/test_version_release.py tests/specify_cli/selfs/test_command_upgrade.py -q: 180 passed, 4 skipped.
  • Four new review regressions fail at the preceding PR commit: the two uv layouts and PIPX_HOME=./pipx-home / ../pipx-home. All pass after the fix. Sibling-directory negative controls pass before and after. The original change had twelve failing layout regressions on base.
  • Installed the patched package using pipx into an isolated relative PIPX_HOME; its real environment entrypoint detects pipx during self upgrade --dry-run --tag v1.2.3. No upgrade was executed. pipx's copied external Windows shim remains unrecognized, as noted above.
  • The latest two UV_TOOL_DIR=./tools / ../tools regressions fail on the preceding PR commit and pass after this fix. Sibling-directory controls and relative XDG rejection pass. An isolated non-editable uv tool install with a relative UV_TOOL_DIR detects uv tool through the real installed executable during self upgrade --dry-run; no upgrade was executed.
  • CLI help and git diff --check pass. Ruff reports the same seven existing findings on base and head, with no added findings.
  • macOS/Linux folder layouts are fixtures on Windows, not native installations. The full repository suite was not run.

Latest tilde-semantics validation: four new regressions fail at the preceding PR head and pass after this correction. Positive literal-tilde uv paths, negative home-expanded uv paths, both XDG tool layouts and existing pipx tilde controls are covered. uv tool dir with a literal UV_TOOL_DIR=~/tools confirms the working-directory interpretation. CLI help and the diff check pass; Ruff retains the same seven base findings.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance

OpenAI Codex (GPT-6), operating autonomously on behalf of Shubham-Padkonde, investigated the issue and review feedback, wrote code/tests/documentation, ran validation, and drafted this description. The exact model variant/reasoning setting is not exposed to the agent. No personal line-by-line human review is claimed. Agent-authored commits identify assistance in their trailers.

Assisted-by: Codex (model: GPT-6, autonomous)
@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Oct 25, 2026
@mnriem
mnriem requested a max review from Copilot October 26, 2026 13:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A verified gap in tilde-prefixed PIPX_HOME handling still prevents valid relocated installations from being upgraded.

1 open issue
What changed in this PR

Extends Specify CLI’s install detection so specify self upgrade can recognize relocated uv and pipx installations, targeting the problem reported in #5095.

Changes:

  • Adds relocation variables and current platform defaults while retaining legacy paths.
  • Adds regression cases for supported layouts, sibling-directory rejection, and unset or empty variables.
  • Documents the environment settings needed when upgrading relocated installations.
File Description
tests/​specify_cli/​test_version_detection.py Adds positive and negative relocation-detection cases.
src/​specify_cli/​_version.py Expands installer prefixes and ignores unconfigured directory variables.
docs/​upgrade.md Explains relocation support and required environment settings.

Review effort: Max

Comment thread src/specify_cli/_version.py Resolved
@mnriem

mnriem commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@mnriem mnriem added the author-awaiting Waiting on author response label Oct 26, 2026
Assisted-by: Codex (model: GPT-6, autonomous)
@mnriem
mnriem requested a max review from Copilot October 26, 2026 16:31
@mnriem mnriem removed the author-awaiting Waiting on author response label Oct 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Valid installation configurations still fall through to unsupported detection.

2 open issues
1 resolved since last review

Review effort: Max

Comment thread src/specify_cli/_version.py Resolved
Comment thread src/specify_cli/_version.py Resolved
@mnriem

mnriem commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

@mnriem mnriem added the author-awaiting Waiting on author response label Oct 26, 2026
Preserve path boundaries and unset-variable guards while resolving
PIPX_HOME against the installer working directory. Add current Windows
and legacy macOS uv layouts with positive and sibling-path regressions.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
@mnriem
mnriem requested a max review from Copilot October 27, 2026 18:01
@mnriem mnriem removed the author-awaiting Waiting on author response label Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Relative UV_TOOL_DIR installations are still misclassified as unsupported.

1 open issue
2 resolved since last review

Review effort: Max

Comment thread src/specify_cli/_version.py Resolved
Resolve UV_TOOL_DIR against the working directory while preserving sibling boundaries and rejecting relative XDG_DATA_HOME prefixes.

Assisted-by: OpenAI Codex (model: GPT-6, autonomous)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed for an unpublished path-handling finding that can misidentify existing installations and bypass relative-path validation.

No open issues 🎉

1 resolved since last review

Review effort: Max

@mnriem

mnriem commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Could you make the tilde expansion specific to the variable being handled? The unpublished finding itself isn’t visible, but focused checks of the base and head code reproduce a problem at _expand_prefix(): expanding ~ after substituting every environment variable accepts XDG_DATA_HOME='~/custom-data', even though XDG requires relative values to be ignored. It also interprets UV_TOOL_DIR='~/tools' as a home-directory path, whereas uv treats that literal ~ as a directory under the working directory. This can misidentify the installation and select an installer targeting a different location. The PIPX_HOME tilde expansion is appropriate and should remain. Could you preserve those variable-specific semantics and add regressions for tilde-prefixed XDG and uv values? The existing relative-XDG test covers only ./data. This establishes a detection/validation defect, not demonstrated code execution or privilege escalation. AI-assisted assessment prepared for @mnriem by GitHub Copilot (GPT-6.1 Sol, automated analysis; no personal human review claimed).

@mnriem mnriem added the author-awaiting Waiting on author response label Nov 2, 2026
Assisted-by: OpenAI Codex (model: GPT-6, autonomous)
Copilot AI max review requested due to automatic review settings November 3, 2026 04:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

@mnriem, the variable-specific tilde handling is corrected at 1748d34: PIPX_HOME expands ~, UV_TOOL_DIR keeps it literal relative to the working directory, and tilde-prefixed XDG_DATA_HOME is rejected as relative.

The November 3 validation recorded four regressions failing on the preceding head and passing after the fix. The six focused version/upgrade test files report 180 passed and four skipped on Windows/Python 3.14.6. The updated description includes the literal-tilde uv tool dir check and the remaining platform/full-suite limitations. Could you re-review this revision?

Posted on behalf of Shubham-Padkonde by OpenAI Codex (GPT-6, autonomous; exact model variant and reasoning setting are not exposed). Codex prepared the earlier code and validation and this review summary; no independent personal human review is claimed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-awaiting Waiting on author response triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: specify self upgrade reports "unsupported" for uv tool installs under XDG_DATA_HOME (and likely for current pipx installs)

3 participants