contao-community-alliance / composer-client

This is the Contao Composer Client
http://de.contaowiki.org/Composer
27 stars 18 forks source link

CaBundleWorkaround leads to fatal error with new composer.phar #288

Closed fritzmg closed 8 years ago

fritzmg commented 8 years ago

With the newest composer.phar and composer-client 0.16.3 the following error happens when accessing the package management in the backend:

[13-Apr-2016 15:23:28 Europe/Vienna] PHP Fatal error: Uncaught exception 'BadMethodCallException' with message 'Entry res/cacert.pem does not exist' thrown in …/system/modules/!composer/src/Util/CaBundleWorkaround.php on line 65
#0 …/system/modules/!composer/src/Util/CaBundleWorkaround.php(65): Phar->offsetGet('res/cacert.pem')
#1 …/system/modules/!composer/src/Runtime.php(531): ContaoCommunityAlliance\Contao\Composer\Util\CaBundleWorkaround::setCaFileIfOpenBaseDirInUse(Object(Phar))
#2 …/system/modules/!composer/src/ClientBackend.php(290): ContaoCommunityAlliance\Contao\Composer\Runtime::registerComposerClassLoader()
#3 …/system/modules/!composer/src/ClientBackend.php(125): ContaoCommunityAlliance\Contao\Composer\ClientBackend->loadComposer()
#4 …/system/modules/core/classes/Backend.php(262): ContaoCommunityAlliance\Contao\Composer\ClientBackend->generate()
#5 …/contao/main.php(137): Contao\Backend->getBackendModule('composer')
#6 …/contao/main.php(288): Main->run()
#7 {main}

This will probably affect a lot more installations soon, as more composer.phar files get auto-updated.

fritzmg commented 8 years ago

The CAFile was removed in this commit: https://github.com/composer/composer/commit/592374ea937322b97bb885b673e6b1443fc02604 It is still present in the 1.0.0 release though: https://github.com/composer/composer/blob/1.0.0/res/cacert.pem

fritzmg commented 8 years ago

This issue cannot be easily worked around either. Even if you set

$GLOBALS['TL_CONFIG']['composerAutoUpdateLibrary'] = false;

in your localconfig.php and download the 1.0.0 release of the composer.phar, the composer-client will still auto-update the composer.phar to the latest snapshot, because !$composerDevWarningTime will be true in this condition:

if (!$composerDevWarningTime
    || $GLOBALS['TL_CONFIG']['composerAutoUpdateLibrary']
       && ($incompatibleVersion || time() > $composerDevWarningTime)
) {
    Runtime::updateComposer();
    Messages::addConfirmation($GLOBALS['TL_LANG']['composer_client']['composerUpdated']);
}

/system/modules/!composer/src/ClientBackend.php#L274

So to actually work around it, you have to manually disable those lines of code.

fritzmg commented 8 years ago

There is actually a new package called composer/ca-bundle now. It provides the following methods:

CaBundle::getSystemCaRootBundlePath() // Returns the system CA bundle path, or a path to the bundled one as fallback
CaBundle::getBundledCaBundlePath() // Returns the path to the bundled CA file
…

composer/composer/issues/5188 https://github.com/composer/composer/pull/5177#issuecomment-208416720

fritzmg commented 8 years ago

hotfix/0.16.4 seems to work fine on tested affected systems

Olli commented 8 years ago

With hotfix/0.16.4 I got

  [ContaoCommunityAlliance\Composer\Plugin\DuplicateContaoException]                                                                             
  Warning: Contao core was about to get installed but has been found in project root, to recover from this problem please restart the operation  
fritzmg commented 8 years ago

Did you do what the warning said? i.e. start the composer update again?

Or are you stuck in an infinite update loop? I got the same problem once with hotfix/0.16.3: #278 Someone on the forum is also stuck in such a loop: https://community.contao.org/de/showthread.php?61071-Paketverwaltung-Problem-open_basedir-composer&p=405740&viewfull=1#post405740

fritzmg commented 8 years ago

@Olli download composer 1.0.2 and copy to /composer, then try to run the composer update again and see if that fixes the update loop.

Olli commented 8 years ago

Did fix nothing. I got the same error (https://github.com/contao-community-alliance/composer-client/issues/288#issuecomment-211278833). 10 times starting update doesn't help. I got this error on console.

Floxn commented 8 years ago

get another error with hotfix/0.16.4 and composer 1.0.2 phar:

Fatal error: Uncaught exception 'PharException' with message '__HALT_COMPILER(); must be declared in a phar' in /xxx/contao/update.phar.php:22 Stack trace: #0 /xxx/contao/update.phar.php(22): Phar::webPhar('update.phar.php', 'index.php', '', Array, 'phar_rewrite') #1 {main} thrown in /xxx/contao/update.phar.php on line 22

fritzmg commented 8 years ago

@Floxn when exactly do you get that error?

Floxn commented 8 years ago

when i start the live update

fritzmg commented 8 years ago

The Live Update? Do you mean the composer update? i.e. when you click on "Update packages"?

Floxn commented 8 years ago

yes the live update

Floxn commented 8 years ago

got the error of your first post on live update, too

fritzmg commented 8 years ago

Sorry, I am still confused. The contao live update is something completely different. Are you refering to "Update packages" in the "Package management"?

Floxn commented 8 years ago

Oh Sorry, just mixed up the composer and live update.

Creasign commented 8 years ago

Hi. The hotfix is working fine at the beginning, but sooner or later I have the same problems again. I think after "legacy packages repository was added to root composer.json" it stops working. It stops working, when I migrate extensions or I want to install a package. Fresh installation of the hotfix on a fresh Contao 3.5.12. I have the same error mentioned in the opening thread.

discordier commented 8 years ago

Are you sure you get the exact same error? Did you upgrade and by accident therefore then downgraded the composer-client from hotfix back to 0.16.3?

Creasign commented 8 years ago

Yes, based ob the error.log. I had the same idea of a downgrade, but how can i check this why could this happen?

Olli commented 8 years ago

Thanks - works fine. :)