fxpio / foxy

A fast, reliable, and secure NPM/Yarn/pnpm bridge for Composer
https://foxypkg.com
MIT License
173 stars 21 forks source link

Issues with composer 2.1 #37

Closed Defcon0 closed 3 years ago

Defcon0 commented 3 years ago

Hello,

I tested foxy with the new composer version 2.1 with the following result:

PHP Fatal error:  Uncaught TypeError: Argument 3 passed to Composer\Package\Locker::__construct() must be an instance of Composer\Installer\InstallationManager, instance of Composer\Repository\RepositoryManager given, called in /home/dev/some_dir/acme/project/vendor/foxy/foxy/Util/LockerUtil.php on line 41 and defined in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php:60
Stack trace:
#0 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Util/LockerUtil.php(41): Composer\Package\Locker->__construct()
#1 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Fallback/ComposerFallback.php(101): Foxy\Util\LockerUtil::getLocker()
#2 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Foxy.php(179): Foxy\Fallback\ComposerFallback->save()
#3 [internal function]: Foxy\Foxy->init()
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(190): call_user_func()
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.p in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php on line 60

Fatal error: Uncaught TypeError: Argument 3 passed to Composer\Package\Locker::__construct() must be an instance of Composer\Installer\InstallationManager, instance of Composer\Repository\RepositoryManager given, called in /home/dev/some_dir/acme/project/vendor/foxy/foxy/Util/LockerUtil.php on line 41 and defined in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php:60
Stack trace:
#0 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Util/LockerUtil.php(41): Composer\Package\Locker->__construct()
#1 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Fallback/ComposerFallback.php(101): Foxy\Util\LockerUtil::getLocker()
#2 /home/dev/some_dir/acme/project/vendor/foxy/foxy/Foxy.php(179): Foxy\Fallback\ComposerFallback->save()
#3 [internal function]: Foxy\Foxy->init()
#4 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(190): call_user_func()
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.p in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php on line 60

It seems foxy is not yet compatible with 2.1, or do I need to configure something?

Thanks!

Bye Defcon0

francoispluchino commented 3 years ago

At first glance, it looks like he had some changes at the level of the manufacturer of the Locker.

SamMousa commented 3 years ago

Actually @francoispluchino it is a simpler issue:

public static function getLocker(IOInterface $io, RepositoryManager $rm, InstallationManager $im, $composerFile)
    {
        $lockFile = str_replace('.json', '.lock', $composerFile);
        // @codeCoverageIgnoreStart
        return \defined('Composer\Composer::RUNTIME_API_VERSION') && '2.0.0' === Composer::RUNTIME_API_VERSION
            ? new Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile))
            : new Locker($io, new JsonFile($lockFile, null, $io), $rm, $im, file_get_contents($composerFile));
    }

The fix you created for 2.0 is not being applied to 2.1!

rjbain commented 2 years ago

I'm getting this error with Composer version 2.2.6:

Fatal error: Uncaught TypeError: Argument 3 passed to Composer\Package\Locker::__construct() must be an instance of Composer\Installer\InstallationManager, instance of Composer\Repository\RepositoryManager given, called in /Users/[redacted]/.composer/vendor/foxy/foxy/Util/LockerUtil.php on line 41 and defined in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php:63
Stack trace:
#0 /Users/[redacted]/.composer/vendor/foxy/foxy/Util/LockerUtil.php(41): Composer\Package\Locker->__construct(Object(Composer\IO\ConsoleIO), Object(Composer\Json\JsonFile), Object(Composer\Repository\RepositoryManager), Object(Composer\Installer\InstallationManager), '{\n  "name": "pa...')
#1 /Users/[redacted]/.composer/vendor/foxy/foxy/Fallback/ComposerFallback.php(101): Foxy\Util\LockerUtil::getLocker(Object(Composer\IO\ConsoleIO), Object(Composer\Repository\RepositoryManager), Object(Composer\Installer\InstallationManager), './composer.json')
#2 /Users/[redacted]/.composer/vendor/foxy/foxy/Foxy.php(179): Foxy\Fallback\ComposerFallback->save()
#3 [in in phar:///usr/local/bin/composer/src/Composer/Package/Locker.php on line 63
francoispluchino commented 2 years ago

@rjbain Fixed in v1.1.1, but you can use the last stable version v1.1.2.