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

Composer 2.0 compatibility #5033

Closed
tobias-kuendig opened this issue Apr 8, 2020 · 28 comments · Fixed by #5506
Closed

Composer 2.0 compatibility #5033

tobias-kuendig opened this issue Apr 8, 2020 · 28 comments · Fixed by #5506

Comments

@tobias-kuendig
Copy link
Member

tobias-kuendig commented Apr 8, 2020

It seems like composer 2.0 is right around the corner. Downloading https://getcomposer.org/composer.phar already gives you a 2.0 build.

Our deployments just started to fail because of this. It seems like there is an issue with the composer-merge-plugin, as it explicitly requires composer 1.1:
https://github.com/wikimedia/composer-merge-plugin/blob/master/composer.json#L15

I have opened an issue on the plugins' GitHub page:
wikimedia/composer-merge-plugin#184

I guess this needs a bump of the wikimedia/composer-merge-plugin dependency in October once a new version has been released.

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires wikimedia/composer-merge-plugin 1.4.1 -> satisfiable by wikimedia/composer-merge-plugin[v1.4.1].
    - wikimedia/composer-merge-plugin v1.4.1 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match your constraint.
@idpsycho
Copy link

idpsycho commented Apr 8, 2020

It has been happening everywhere for a few days now, happens to everyone in our team.

TEMPORARY solution:

composer create october/october .
composer i --ignore-platform-reqs

@mohsin
Copy link
Contributor

mohsin commented Apr 15, 2020

I'm getting a similar issue which I believe is related to this. Surprising that the error message makes no sense because I'm using php 7.2 when the minimal requirement is 7.0 as per the platform.
Screen Shot 2020-04-15 at 9 56 31 AM

@bennothommo
Copy link
Contributor

bennothommo commented Apr 15, 2020

@SaifurRahmanMohsin The issue is we use the config key in composer.json to lock the version of PHP to 7.0. @daftspunk's reasoning for the change can be found here. If this issue occurs for you, you can either remove the config key in composer.json, use @idpsycho's suggestion above, or use the wip/laravel-6 branch.

@LukeTowers
Copy link
Contributor

@bennothommo using the L6 branch in @SaifurRahmanMohsin's case isn't the problem, he needs to update his composer.json to pull in 1.4.1 of the merge plugin instead of using dev-master. It's unfortunate that we were using dev-master in the first place, every project that's ever been pulled down before the recent fix will still have the broken version in their composer.json.

@tinh1115
Copy link

Downgrade to 1.9.2 works for me, but in different project.

@github-actions
Copy link

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@bennothommo
Copy link
Contributor

Marking this as In Progress as Wikimedia are working on it, and just so this doesn't get archived again.

@prhost
Copy link
Member

prhost commented Oct 30, 2020

Hello, I tested it on the branch dev-composer20 (https://github.com/wikimedia/composer-merge-plugin/tree/composer20) and presented the error below. We will probably have to wait for a stable release from them before we update.

Screen Shot 2020-10-30 at 18 09 24

@prhost
Copy link
Member

prhost commented Oct 30, 2020

Hello, I tested it on the branch dev-composer20 (https://github.com/wikimedia/composer-merge-plugin/tree/composer20) and presented the error below. We will probably have to wait for a stable release from them before we update.

Screen Shot 2020-10-30 at 18 09 24

I made an adjustment for them that corrects this problem, let's see if they approve, I tested here with my fork and october, and ran the tests well on a large project with more than 40 plugins and with october developer branch and everything went well.

@LukeTowers
Copy link
Contributor

@prhost please test wikimedia/composer-merge-plugin#189 (comment) against October, that's the PR that adds full 2.0 support to the merge plugin.

@prhost
Copy link
Member

prhost commented Nov 2, 2020

I tested it here, my project ran fine with laravel 6. but I ran phpunit and presented the error below:

PHPUnit 8.5.8 by Sebastian Bergmann and contributors.

...............................................................  63 / 505 ( 12%)
............................................................... 126 / 505 ( 24%)
............................................................... 189 / 505 ( 37%)
............................................................... 252 / 505 ( 49%)
............................................................... 315 / 505 ( 62%)
...........................................................S... 378 / 505 ( 74%)
............................................................... 441 / 505 ( 87%)
............................................EEEEEE............. 504 / 505 ( 99%)
.                                                               505 / 505 (100%)

Time: 1.92 minutes, Memory: 92.50 MB

There were 6 errors:

1) HelpersTest::testConfigPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

2) HelpersTest::testPluginsPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

3) HelpersTest::testThemesPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

4) HelpersTest::testTempPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

5) HelpersTest::testUploadsPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

6) HelpersTest::testMediaPath
Error: Class 'Mockery' not found

/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:116
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:100
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:88
/Users/kallef/PhpstormProjects/orbital/october-develop/vendor/october/rain/tests/Support/HelpersTest.php:18

ERRORS!
Tests: 505, Assertions: 2890, Errors: 6, Skipped: 1.
➜  october-develop git:(develop) ✗ 

@LukeTowers
Copy link
Contributor

@bennothommo ^

@bennothommo
Copy link
Contributor

@LukeTowers fixed: fffa6db

@prhost
Copy link
Member

prhost commented Nov 4, 2020

Thanks @bennothommo, it worked. However @LukeTowers I believe that this version of the composer-merge-plugin did not work for us, what we really should do is to merge the vendor autoload of a plugin with the main autoload did not work.

I tested it by installing October.Drivers and creating an instance of Aws, one of the packages installed by him.

Screen Shot 2020-11-04 at 11 12 41

@LukeTowers
Copy link
Contributor

@prhost how did you install the package?

@prhost
Copy link
Member

prhost commented Nov 5, 2020

@prhost how did you install the package?

php artisan plugin:install Orctober.Drivers

Within this plugin is the vendor folder plugins/october/drivers/vendor, in theory composer-plugin-merge should recognize that vendor and merge with the main vendor.

I remember that there was a native october class that did this job, I don't know why @daftspunk left the previous class to use composer-plugin-merge. Maybe save maintenance. I know 🤷🏻‍♂️

@LukeTowers
Copy link
Contributor

@prhost that native class still exists, it handles marketplace plugins, which if you run plugin:install is what you have. The composer-merge-plugin has nothing to do with marketplace plugins or plugins with vendor directories in the plugin folder. It simply merges the project composer.json with any composer.json files present in the plugins so that all project dependencies are loaded in the main project vendor folder.

@anilloutombam

This comment has been minimized.

@bennothommo
Copy link
Contributor

@anilloutombam We are aware of the error message - you do not need to re-paste the same error message, nor create another issue with the exact same message.

@anilloutombam
Copy link

What is the solution for now @bennothommo

@bennothommo
Copy link
Contributor

@anilloutombam Download Composer 1.10.17 locally into your October CMS folder and run that directly.

@koesper
Copy link

koesper commented Nov 11, 2020

If you happen to run into this problem when your build pipeline throws errors with composer v2, while it worked on v1. This might work:

composer self-update --1

This workaround makes sure that your pipeline runs Composer v1.x instead of v2

Suggestion found in the release notes:
https://github.com/composer/composer/releases/tag/2.0.0-RC2

@LukeTowers
Copy link
Contributor

Worth noting that if you manually add the repository from here: wikimedia/composer-merge-plugin#189 (comment) and switch to the 2.0 patch branch in your project's composer.json it seems to work fine with 2.0. Using it on all my projects right now.

@everyx
Copy link
Contributor

everyx commented Dec 14, 2020

Thanks @bennothommo, it worked. However @LukeTowers I believe that this version of the composer-merge-plugin did not work for us, what we really should do is to merge the vendor autoload of a plugin with the main autoload did not work.

I tested it by installing October.Drivers and creating an instance of Aws, one of the packages installed by him.

Screen Shot 2020-11-04 at 11 12 41

@prhost I meet this problem too, do you have any workaround for this?

@everyx
Copy link
Contributor

everyx commented Dec 14, 2020

@prhost that native class still exists, it handles marketplace plugins, which if you run plugin:install is what you have. The composer-merge-plugin has nothing to do with marketplace plugins or plugins with vendor directories in the plugin folder. It simply merges the project composer.json with any composer.json files present in the plugins so that all project dependencies are loaded in the main project vendor folder.

@LukeTowers looks like the plugins' composer.json not loaded in the main project vendor folder in v1.1.1, how can I get this wokr?

@LukeTowers
Copy link
Contributor

@everyx what makes you think that's the case? Did you remove any vendor directory from the plugin folder itself and run composer update from the project root?

@everyx
Copy link
Contributor

everyx commented Dec 15, 2020

@everyx what makes you think that's the case? Did you remove any vendor directory from the plugin folder itself and run composer update from the project root?

@LukeTowers thanks your reply, and I have solved this problem by

# disable scripts
composer create-project --no-scripts october/october . 1.1.1;
# and run discover manually
php artisan package:discover;

@VolCh
Copy link
Contributor

VolCh commented Feb 13, 2021

wikimedia/composer-merge-plugin#189 has been merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.