Skip to content

fix: improve global self-update scope detection#337

Merged
coisa merged 5 commits into
mainfrom
fix/336-self-update-global-scope
May 11, 2026
Merged

fix: improve global self-update scope detection#337
coisa merged 5 commits into
mainfrom
fix/336-self-update-global-scope

Conversation

@coisa
Copy link
Copy Markdown
Contributor

@coisa coisa commented May 11, 2026

Related Issue

Closes #335

Motivation / Context

dev-tools self-update was still behaving as local in certain environments (symlinked/alternate Composer home paths), so global updates could route through local project contexts.

The branch introduces a more robust Composer scope detection flow for self-update, including:

  • safer composer-home path normalization (with realpath/canonicalization fallback),
  • recognition of XDG_CONFIG_HOME/composer as a valid Composer home candidate, and
  • stronger candidate matching logic before deciding local vs global scope.

Changes

  • Restore/extend self-update home-path canonicalization in ComposerSelfUpdateScopeResolver.
  • Add Composer XDG_CONFIG_HOME as an additional resolution candidate for global composer home detection.
  • Added/updated unit coverage in ComposerSelfUpdateScopeResolverTest for the new candidate path.

Verification

  • composer dev-tools via commit-time hook
  • Focused command(s): pre-commit validation ran during commit
  • Manual verification: reproducible global-vs-local scope behavior should be revalidated with symlinked/alternate composer home flows

Documentation / Generated Output

  • README updated
  • docs/ updated
  • Generated or synchronized output reviewed

Changelog

  • Added a notable CHANGELOG.md entry

Reviewer Notes

This is the intermediate self-update fix requested before full git-hooks externalization; the issue-specific change is intentionally scoped.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1b54c269-6239-4de0-8965-3aeb73688148

📥 Commits

Reviewing files that changed from the base of the PR and between 18d1cf4 and 1a3bef2.

📒 Files selected for processing (4)
  • .github/wiki
  • CHANGELOG.md
  • src/SelfUpdate/ComposerSelfUpdateScopeResolver.php
  • tests/SelfUpdate/ComposerSelfUpdateScopeResolverTest.php

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved self-update global/local scope detection to correctly handle symlinked Composer home environments and added support for XDG_CONFIG_HOME, preventing unintended global installs from being treated as local updates.
  • Tests
    • Added tests covering Composer home detection including XDG_CONFIG_HOME scenarios.
  • Documentation
    • Updated changelog noting the fix and scope-detection improvements.

Walkthrough

The PR hardens global installation detection in ComposerSelfUpdateScopeResolver by introducing path normalization with symlink resolution and adding XDG_CONFIG_HOME support for Composer home discovery. A wiki submodule reference is also updated.

Changes

Global Installation Detection with XDG Support

Layer / File(s) Summary
Path normalization helper
src/SelfUpdate/ComposerSelfUpdateScopeResolver.php
New normalizePath() method resolves symlinks via realpath() with fallback to direct canonicalization when resolution fails; imports updated to support safe realpath usage.
Composer home candidate discovery
src/SelfUpdate/ComposerSelfUpdateScopeResolver.php
getComposerHomeCandidates() adds XDG_CONFIG_HOME/composer as a candidate path alongside existing COMPOSER_HOME, HOME, macOS, and APPDATA variants.
Global installation detection
src/SelfUpdate/ComposerSelfUpdateScopeResolver.php
isGlobalInstallation() now uses normalized paths for comparisons, enabling robust detection in setups with symlinked Composer homes.
Test coverage and validation
tests/SelfUpdate/ComposerSelfUpdateScopeResolverTest.php
Existing test cases explicitly mock XDG_CONFIG_HOME as null; new test verifies isGlobalInstallation() returns true when package is under an XDG_CONFIG_HOME-derived Composer home.
Changelog documentation
CHANGELOG.md
Documents improved self-update global/local scope detection with realpath fallback and XDG_CONFIG_HOME support.

Submodule Reference Update

Layer / File(s) Summary
Wiki submodule commit update
.github/wiki
The .github/wiki git subproject reference is updated to a newer commit.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Paths unwound from their tangled links,
XDG homes found in symlink shrinks,
A global detection gets quite shrewd—
No more confusion from forked nodes!
Hops of code now find their rightful paths.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/336-self-update-global-scope

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

@coisa coisa merged commit 7abc73d into main May 11, 2026
32 checks passed
@coisa coisa deleted the fix/336-self-update-global-scope branch May 11, 2026 20:29
@github-project-automation github-project-automation Bot moved this from Backlog to Released in PHP Fast Forward Project May 11, 2026
github-actions Bot added a commit that referenced this pull request May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

self-update may update local project when running global binary via symlinked composer home

1 participant