magento / composer

Open Software License 3.0
31 stars 23 forks source link

Make compatible with composer v2 #28

Closed hostep closed 3 years ago

hostep commented 3 years ago

Hi folks

Can this module be made compatible with composer v2? Or maybe research to see why this module is needed and consider removing it from core Magento?

In order to prevent https://github.com/composer/composer/issues/9717 to happen again in the future. (Update: this was a bug in composer/composer, not in magento/composer)

/cc @fascinosum, @mmansoor-magento, @pdohogne-magento

Thanks!

fascinosum commented 3 years ago

hi @hostep, we are going to make this module compatible with Composer 2 for the 2.3.7 release and for the next 2.4 release too As you well know, if Magento had installed Composer 2 as dependency, it would only hide the real issue in composer/composer#9717 P.S. @hostep thank you for reporting the composer issue

YiffyToys commented 3 years ago

Magento 2.4.2 is supposed to be compatible with composer 2 according to the release notes https://devdocs.magento.com/guides/v2.4/release-notes/open-source-2-4-2.html "Magento 2.4.2 is now compatible with Composer 2.x. We recommend that merchants migrate to Composer 2.x. " and indeed

magento/product-community-edition     2.4.2    requires  composer/composer (^1.9 || ^2.0)

but

magento/product-community-edition  2.4.2  requires  magento/composer (1.6.0)
magento/composer                      1.6.0    requires  composer/composer (^1.9)
fascinosum commented 3 years ago

hi @YiffyToys, Magento 2.4.2 is compatible with Composer 2 as a tool. We have Composer 1 as installed dependency, but this does not affect deployment process. As I mentioned above, next Magento 2.4 release will support Composer 2 as a dependency

convenient commented 3 years ago

I've got a small use case where this is giving me bother, I have a need to run a composer command after a successful composer install completes.

Something like this in my composer.json

    "scripts": {
        "post-install-cmd": [
            "[ $COMPOSER_DEV_MODE -eq 0 ] || which composer",
            "[ $COMPOSER_DEV_MODE -eq 0 ] || composer --version"
        ]
    },

When composer runs it stacks ./vendor/bin onto the $PATH. This means that I am actually using composer1 when doing commands like the above

[14:15:26] lukerodgers [~/src/project]$ composer --version
Composer version 2.0.13 2021-04-27 13:11:08

[14:16:57] lukerodgers [~/src/project]$ composerinstall
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
> [ $COMPOSER_DEV_MODE -eq 0 ] || which composer
/Users/lukerodgers/src/project/vendor/bin/composer
> [ $COMPOSER_DEV_MODE -eq 0 ] || composer --version
The "eloquent/composer-npm-bridge" plugin was skipped because it requires a Plugin API version ("^2") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
Composer 1.10.22 2021-04-27 13:10:45

You can see there that its picking up the composer version brought in by this module (vendor/bin/composer) which is less than ideal as it is version 1.10.22 and not a v2 series.

convenient commented 3 years ago

The following seems to work

    "scripts": {
        "post-install-cmd": [
            "[ $COMPOSER_DEV_MODE -eq 0 ] || $COMPOSER_BINARY --version"
        ]
    },

https://github.com/composer/composer/blob/49d7ff1626044e0885c351ef283863876466dd41/bin/composer#L61

hostep commented 3 years ago

Let's close this ticket, version 1.7.0 of this module was made compatible with composer version 2