GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Composer global-home fallback checks ~/.composer before the XDG home, so scan -g finds no Composer 2 global packages when a stale ~/.composer exists and composer isn't on PATH · Issue #586 · SocketDev/socket-patch

Composer global-home fallback checks ~/.composer before the XDG home, so scan -g finds no Composer 2 global packages when a stale ~/.composer exists and composer isn't on PATH #586

New issue
Copy link
New issue
Copy link
Closed
#1421
Closed
Composer global-home fallback checks ~/.composer before the XDG home, so scan -g finds no Composer 2 global packages when a stale ~/.composer exists and composer isn't on PATH#586
#1421
Copy link
Labels
agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:composerComposerComposerpriority:p2

Description

@mikolalysenko
Mikola Lysenko (mikolalysenko)
opened on Oct 2, 2026
Issue body actions

[agent] Found by the scheduled Composer bug-hunt routine (ledger #321).

Summary

When composer global config home can't be run (composer isn't on PATH, for example when it's installed as composer.phar or behind an alias), get_composer_home falls back to composer_home_candidates, added in #442 for #438. That function tries ~/.composer before $XDG_CONFIG_HOME/composer / ~/.config/composer and returns the first directory that exists. Composer 2 uses the opposite order. On an XDG system (any XDG_* env var set, or /etc/xdg present, i.e. most Linux distros), Factory::getHomeDir tries the XDG dir first and only falls back to ~/.composer. Composer 1 does use ~/.composer first.

So on Linux with Composer 2, any leftover ~/.composer directory (even an empty one, e.g. from the Composer 1 era) hides the real global home. scan -g prints "No global packages found." and exits 0, and apply -g / vex -g silently do nothing to the real global install.

The doc comment at composer_home_candidates ("elsewhere: ~/.composer when it exists, else the XDG location") states Composer's rule backwards for Composer 2.

Impact

Globally installed Composer tools (phpunit, php-cs-fixer, laravel/installer, …) go silently unpatched, with a success exit code, on Linux machines that have both directories and no composer on PATH. Same symptom class as #438.

Repro (Linux, PHP 8.3, Composer 2.10.3 phar, main 203e092)

B=$(mktemp -d); mkdir -p $B/home/.composer $B/home/.config/composer $B/proj $B/nopath
ln -s "$(command -v php)" $B/nopath/php
export HOME=$B/home; unset COMPOSER_HOME XDG_CONFIG_HOME
php composer-2.10.3.phar global config home      # -> $B/home/.config/composer
php composer-2.10.3.phar global require psr/log:1.1.4 -n
ls $HOME/.config/composer/vendor/composer/installed.json   # the real global install
cd $B/proj
# a local mock answering POST /patch/batch on 127.0.0.1:8765 logs the queried purls
PATH=$B/nopath socket-patch scan -g -e composer --json --proxy-url http://127.0.0.1:8765
#   -> "scannedPackages": 0, no /patch/batch request ("No global packages found." in text mode, exit 0)
PATH="$PATH" socket-patch scan -g -e composer --json --proxy-url http://127.0.0.1:8765   # composer on PATH (control)
#   -> "scannedPackages": 1, batch queries pkg:composer/psr/[email protected]
rmdir $HOME/.composer; PATH=$B/nopath socket-patch scan -g -e composer --json ...        # control
#   -> "scannedPackages": 1

The same happens with XDG_CONFIG_HOME=$B/xdg and the global install in $B/xdg/composer.

Expected vs actual

  • Expected: -g operates on the global install Composer itself uses (get_composer_home mirrors Factory::getHomeDir, per its doc comment and the On Windows, scan -g finds no Composer global packages in the default %APPDATA%\Composer home, so apply -g and vex -g silently do nothing #438 fix). Composer 2: $XDG_CONFIG_HOME/composer or ~/.config/composer first when XDG is in use, then ~/.composer.
  • Actual: ~/.composer wins whenever it exists, and 0 packages are scanned with exit 0.

Matrix (Linux, PHP 8.3; each scan run twice, same result)

Composer Composer's own home (both dirs exist) socket-patch, no composer on PATH control: on PATH control: no ~/.composer
1.10.28 ~/.composer (both cases) matches Composer (not affected) n/a n/a
2.2.30 ~/.config/composer / $XDG_CONFIG_HOME/composer 0 packages ×2 layouts n/a n/a
2.10.3 ~/.config/composer / $XDG_CONFIG_HOME/composer 0 packages ×2 layouts 1 package 1 package

macOS: untested. Composer's useXdg() is normally false there (no XDG_* vars, no /etc/xdg), so ~/.composer first is correct, but a macOS user with an XDG_* variable set would hit this. Windows isn't affected (%APPDATA%\Composer comes first).

First bad version

This isn't a regression in #442. The pre-#442 fallback (v4.0.0) already probed ~/.composer before ~/.config/composer. #442 added $XDG_CONFIG_HOME but kept the order.

Suspect code

crates/socket-patch-core/src/crawlers/composer_crawler.rs:407-434 (composer_home_candidates: home.join(".composer") at :424 is pushed before the XDG candidates at :428/:432), consumed at :387-390. A fix needs to mirror useXdg() (any XDG_* env var, or /etc/xdg exists) and, when it's true, put the XDG dir first. Composer 1's order differs, but without a composer binary the version can't be detected cheaply, so preferring the Composer 2 rule (or crawling every existing candidate) seems the safer choice.

Activity

  1. Mikola Lysenko (mikolalysenko)
    added
    bugSomething isn't workingSomething isn't working
    bughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agent
    pm:composerComposerComposer
    on Oct 2, 2026
  2. Mikola Lysenko (mikolalysenko)
    added a commit that references this issue on Oct 2, 2026

    composer: run 9 ledger (#586)

    db78fcc
  3. mikolalysenko commented on Oct 2, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 2, 2026
    CollaboratorAuthor
    More actions

    [agent] Triaged: priority:p2 (Composer). This isn't a duplicate. #438 / #442 added the fallback but kept the Composer 1 order, and I found no open PR. The cause is confirmed in composer_home_candidates (crawlers/composer_crawler.rs), which pushes ~/.composer before the XDG candidates.


    Generated by Claude Code

  4. Mikola Lysenko (mikolalysenko)
    added
    agent:triaged
    priority:p2
    on Oct 2, 2026
  5. mikolalysenko commented on Oct 12, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 12, 2026
    CollaboratorAuthor
    More actions

    [agent] Claiming this issue (shared root cause: the Composer home fallback probes ~/.composer before the XDG home, which is Composer 1's order; Composer 2 checks the XDG home first on XDG systems). Branch: agent/fix-composer-xdg-home-order. Claim-ID: 2026-10-12T07:21:23Z-9d3c73


    Generated by Claude Code

  6. Mikola Lysenko (mikolalysenko)
    added
    agent:claimed
    on Oct 12, 2026
  7. mikolalysenko commented on Oct 12, 2026

    @mikolalysenko
    Mikola Lysenko (mikolalysenko)
    on Oct 12, 2026
    CollaboratorAuthor
    More actions

    [agent] Draft PR: #1421


    Generated by Claude Code

  8. Mikola Lysenko (mikolalysenko)
    added 2 commits that reference this issue on Oct 12, 2026

    Find Composer 2 global home before ~/.composer

    This issue will close once commit 995596e is merged into the 'main' branch.
    995596e

    Tighten Composer XDG home detection

    This issue will close once commit ab0ffcb is merged into the 'main' branch.
    ab0ffcb
  9. Mikola Lysenko (mikolalysenko)
    closed this as completedin #1421on Oct 12, 2026
  10. github-merge-queue
    added a commit that references this issue on Oct 13, 2026

    chore(release): 5.0.1 (#1485)

    2e0a6b9
  11. Mikola Lysenko (mikolalysenko)
    removed
    agent:claimed
    on Oct 15, 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

    agent:triagedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:composerComposerComposerpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.