Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package conflict with installed extension where replaces is used #161

Open
asgrim opened this issue Dec 24, 2024 · 2 comments
Open

Package conflict with installed extension where replaces is used #161

asgrim opened this issue Dec 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@asgrim
Copy link
Collaborator

asgrim commented Dec 24, 2024

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.
@asgrim asgrim added the bug Something isn't working label Dec 24, 2024
@asgrim asgrim self-assigned this Dec 24, 2024
@asgrim asgrim changed the title Package conflict with installed extension Package conflict with installed extension where replaces is used Dec 24, 2024
@Bellangelo
Copy link
Contributor

Hi @asgrim, I think the issue here is that your extension tries to replace itself: https://github.com/asgrim/example-pie-extension/blob/main/composer.json#L13. I tried to create more concrete results through a fork of your extension but my knowledge to the extensions is quite limited and during the renaming of the extension I have only managed to create several bugs 😄

@asgrim
Copy link
Collaborator Author

asgrim commented Jan 4, 2025

It is related to replaces and how Composer resolves dependencies. It makes sense, a fix is being worked on (hence why it is assigned already) 👍 thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants