Skip to content

Set package index repository as non-canonical to allow Packagist to resolve newer versions#222

Merged
swissspidy merged 6 commits intomainfrom
copilot/fix-legacy-package-installation
Feb 26, 2026
Merged

Set package index repository as non-canonical to allow Packagist to resolve newer versions#222
swissspidy merged 6 commits intomainfrom
copilot/fix-legacy-package-installation

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

  • Understand the issue: Legacy WP-CLI Package Index has higher priority than Packagist, preventing installation of newer package versions not listed in the index
  • Add "canonical": false to the WP-CLI Package Index repository configuration in $composer_type_package
  • Update the existing-installation refresh condition to also trigger when canonical is not set to false
  • Update existing Behat test to also assert "canonical": false is present after install
  • Add a new Behat test scenario for updating a repo that has the correct URL but is missing canonical: false
  • Fix CI failure: restore $this->composer_type_package passed directly to addRepository (previously removed accidentally), and remove duplicate log message
Original prompt

This section details on the original issue you should resolve

<issue_title>Legacy package index prevents installation of current release of a package</issue_title>
<issue_description>## Bug Report

Describe the current, buggy behavior

I'm trying to install a package, pressbooks/pb-cli, which is listed in the now-deprecated WP-CLI Package Index.

The current release of the package is 2.1.0 (corresponding to pressbooks/pb-cli@cc81de0). However, installing via the package command always installs the last release listed in the WP-CLI Package Index, which was 2.0.1 (corresponding to pressbooks/pb-cli@9fb35e6). If I try to specify the 2.1.0 version, I get the following error:

Your requirements could not be resolved to an installable set of packages.
Problem 1
    - Root composer.json requires pressbooks/pb-cli 2.1.0, it is satisfiable by pressbooks/pb-cli[2.1.0] from composer repo (https://repo.packagist.org) but pressbooks/pb-cli[dev-master, dev-dev, 1.0.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 2.0.0, 2.0.1] from composer repo (https://wp-cli.org/package-index) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.

Describe how other contributors can replicate this bug

  • Run: wp package install pressbooks/pb-cli
  • Inspect lock file in ~/.wp-cli/packages/composer.lock
  • Observe that the installed version is as follows:
          "name": "pressbooks/pb-cli",
            "version": "dev-master",
            "source": {
                "type": "git",
                "url": "https://github.com/pressbooks/pb-cli.git",
                "reference": "9fb35e6129bbf51b53408671edce9bee5b75964d"
            }
          }
  • Run: wp package uninstall pressbooks/pb-cli
  • Run: wp package install pressbooks/pb-cli:2.1.0
  • Observe the error that ensues:
Your requirements could not be resolved to an installable set of packages.
Problem 1
    - Root composer.json requires pressbooks/pb-cli 2.1.0, it is satisfiable by pressbooks/pb-cli[2.1.0] from composer repo (https://repo.packagist.org) but pressbooks/pb-cli[dev-master, dev-dev, 1.0.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 2.0.0, 2.0.1] from composer repo (https://wp-cli.org/package-index) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.

Describe what you would expect as the correct outcome

As the package index is no longer being updated, I'd expect Packagist to be the higher priority repository.

Let us know what environment you are running this on

OS: Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
Shell: /bin/zsh
PHP binary: /usr/local/Cellar/php@7.4/7.4.20/bin/php
PHP version: 7.4.20
php.ini used: /usr/local/etc/php/7.4/php.ini
MySQL binary: /usr/local/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.5.9-MariaDB, for osx10.16 (x86_64) using readline 5.1
SQL modes: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /Users/ned/Sites/cli-test
WP-CLI packages dir: /Users/ned/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.5.0

Provide a possible solution

There could be a flag to explicitly bypass the WP-CLI Package Index.

Provide additional context

This also happens in GitHub Actions.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…nt it from blocking newer Packagist versions

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix legacy package index installation for current release Set package index repository as non-canonical to allow Packagist to resolve newer versions Feb 25, 2026
@swissspidy swissspidy added this to the 2.6.2 milestone Feb 25, 2026
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Package_Command.php 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

swissspidy and others added 2 commits February 25, 2026 23:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

… in addRepository call

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review February 25, 2026 23:59
@swissspidy swissspidy requested a review from a team as a code owner February 25, 2026 23:59
@swissspidy swissspidy merged commit 2400866 into main Feb 26, 2026
68 of 69 checks passed
@swissspidy swissspidy deleted the copilot/fix-legacy-package-installation branch February 26, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy package index prevents installation of current release of a package

3 participants