ffraenz / private-composer-installer

Composer install helper outsourcing sensitive keys from the package URL into environment variables
MIT License
226 stars 16 forks source link

Class 'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found #38

Closed p-mceldowney closed 2 years ago

p-mceldowney commented 3 years ago

For some reason i'm getting this error when deploying my site after I ran composer update.

PHP
Fatal error: Uncaught Error: Class
'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found in
/www/{site_name}/public/releases/129232182/vendor/ffraenz/private-
composer-installer/src/PrivateComposerInstaller/Plugin.php:102

The error happens at this stage in the deployment Installing advanced-custom-fields/advanced-custom-fields-pro (5.9.1). It's been working fine for months now, so I'm not sure what's going on. Everything works on my local also.

Here's my ACF declaration in my composer.json file.

{
      "type": "package",
      "package": {
        "name": "advanced-custom-fields/advanced-custom-fields-pro",
        "version": "5.9.1",
        "type": "wordpress-muplugin",
        "dist": {
          "type": "zip",
          "url": "https://connect.advancedcustomfields.com/index.php?a=download&p=pro&k={%ACF_PRO_KEY}&t=5.9.1"
        },
        "require": {
          "ffraenz/private-composer-installer": "^5.0",
          "composer/installers": "^1.4"
        }
      }
    },

Has anyone had this issue before?

This site is hosted on Kinsta and is built using trellis/bedrock/sage.

szepeviktor commented 3 years ago

What is your Composer and private-composer-installer version?

szepeviktor commented 3 years ago

BTW Now you can say t={%VERSION}

p-mceldowney commented 3 years ago

private-composer-installer is v5.0.1 Composer is 2.0.3 i did just notice that my remote server is still on composer 1. I'm guessing that could be the issue?

And yeah, I used to use t={%VERSION} but after the October PR it was throwing errors for me for some reason

szepeviktor commented 3 years ago

Yes, Composers should be on a matching version. I recommend v1 as v2 is still fragile.

Composer is 2.0.3

Please upgrade that, it has a grave error.

p-mceldowney commented 3 years ago

Okay i upgraded to 2.0.8. Sorry I'm a bit all over the place right now, but my local server is a vagrant box that's actually on composer 1.10.17 and my remote host is on 1.10.5. My local machine is what's running 2.0.8

p-mceldowney commented 3 years ago

Do you think upgrading my vagrantbox and remote server to Composer 2 will fix this issue? I had issues with private-composer-installer after upgrading to Composer 2 once before but I know where I went wrong with that now.

szepeviktor commented 3 years ago

If there is a bug in private-composer-installer I hope it'll be fixed. So I suggest you to run with Composer v1 everywhere then with v2.

p-mceldowney commented 3 years ago

okay. what's weird about the bug I'm currently getting is that i accidentally had the private-composer-installer version requirement for advanced custom fields set to v5.1 (which isn't even an available version). No error was thrown about that for almost a month and then today I finally got an error about the v5.1 when I ran composer update. So changed the line "ffraenz/private-composer-installer": "^5.1", to "ffraenz/private-composer-installer": "^5.0",. And now i'm getting the "Class 'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found" error on deployment

szepeviktor commented 3 years ago

What is Composer version that generated the lock file and then installed packages in the other environment? I hope these two are the same!

szepeviktor commented 3 years ago

Class 'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found in /www/{site_name}/public/releases/129232182/vendor/ffraenz/private- composer-installer/src/PrivateComposerInstaller/Plugin.php:102

src/PrivateComposerInstaller/ existed up to v4!!!

szepeviktor commented 3 years ago

So changed the line "ffraenz/private-composer-installer": "^5.1", to "ffraenz/private-composer-installer": "^5.0",

Maybe you haven't updated the lock file. Try running composer validate --strict

p-mceldowney commented 3 years ago

I ran composer update from my local machine that is set to composer v2.0.8. And the composer version on my remote server is v1.10.5. And running composer validate --strict just gives a few warnings about using exact version constraints

p-mceldowney commented 3 years ago

So my remote server does appear to not have an updated lock file. The composer.json has "ffraenz/private-composer-installer": "^5.0" but the lock file has "ffraenz/private-composer-installer": "^5.1".

szepeviktor commented 3 years ago

My job is to run web applications therefor I wouldn't like to give advises. All my knowledge is public.

p-mceldowney commented 3 years ago

update:

I've updated everything to run composer 2.0.8 and am still getting 'FFraenz\PrivateComposerInstaller\Environment\LoaderFactory' not found on deployment. I've tried deleting the lock file on my remote server and running composer install again with no luck

szepeviktor commented 3 years ago

I help you for 15 minutes for free viktor@szepe.net We could start with deleting vendor/

ffraenz commented 3 years ago

As of the different capabilities offered by the Composer Plugin Interface you can't downgrade from Composer 2 to Composer 1 when using ffraenz/private-composer-installer as the package dist URLs get encoded differently in composer.lock. You need to upgrade to Composer 2 and use it consistently throughout all environments. The error message you describe may occur when upgrading libraries that have already been loaded into the current PHP context. To fix it, you should try to upgrade dependencies like phpdotenv and private-composer-installer one by one.