Skip to content

Package conflict with installed extension where replaces is used #161

Closed
@asgrim

Description

@asgrim

I think this follows on from #150 - my test extension asgrim/example-pie-extension uses replace, and this is causing issues.

Steps to reproduce:

  • Install the example ext (bin/pie install -v asgrim/example-pie-extension)
  • Then try to install a different, unrelated extension, e.g. (bin/pie install -v xdebug/xdebug)

Expected results:

xdebug should be installed

Actual results:

You are running PHP 8.3.14
Target PHP installation: 8.3.14 ts, on Linux/OSX/etc x86_64 (from /home/james/workspace/oss/php-src-build/bin/php)
Found package: xdebug/xdebug:3.4.0 which provides ext-xdebug
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - ext-example_pie_extension is present at version 0.1.0 and cannot be modified by Composer
    - asgrim/example-pie-extension is locked to version 2.0.2 and an update of this package was not requested.
    - Only one of these can be installed: asgrim/example-pie-extension[2.0.2], ext-example_pie_extension[0.1.0]. asgrim/example-pie-extension replaces ext-example_pie_extension and thus cannot coexist with it.

Observations:

  • The dependency was correctly resolved in \Php\Pie\DependencyResolver\ResolveDependencyWithComposer; so the issue comes from the Composer Installer \Php\Pie\ComposerIntegration\ComposerIntegrationHandler
  • The installed/reported extension version is 0.1.0 (I never updated the PHP_EXAMPLE_PIE_EXTENSION_VERSION constant to be the actual version) but I don't think this is related; even if they were the same version I think it is just the fact that asgrim/example-pie-extension replaces ext-example-pie-extension, but both are present, so Composer has a little meltdown from it
  • The fix I had done in When ext that uses replace is already enabled, Composer will report conflict #150 was to exclude the ext being installed from the reported list of extensions for the \Php\Pie\ComposerIntegration\PhpBinaryPathBasedPlatformRepository, but I don't think this is the right approach. I think perhaps something like: work out if a Composer package (asgrim/example-pie-extension) does a replaces for an extension (example_pie_extension) and exclude all of those when building the platform in PhpBinaryPathBasedPlatformRepository
  • I think this behaviour is strictly related to using replaces in composer.json, which checking into the Packagist extensions list shows that there are only two extensions using this at the moment (asgrim/example-pie-extension, solidworx/aspect), so it is not (yet) a widespread problem at the moment.

Metadata

Metadata

Assignees

Labels

maintainer investigatingThis ticket is being investigated by maintainers. Please check with us before contributing PRs etc!

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions