php / php/pie

self-update does update, but displays class not found error and PHP output due to PHAR content changing

Open
#238 4 comments 0 reactions 1 assignee View on GitHub

@asgrim is already working on this.

Since May 8, 2025.

bug maintainer investigating
Dominant language
PHP
Stars
2k
Forks
73
Avg merge
3h 37m
Merged PRs (30d)
11

Description

We introduced the EventDispatcher in #219 to handle the banner, but this has introduced a side-effect when the PHAR is overwritten (by SelfUpdateCommand), in that the PHAR content has changed and so the subsequent class loads will fail.

Reproducer:

$ php box.phar compile && php pie.phar self-update --nightly
<box compile snipped>
🥧 PHP Installer for Extensions (PIE) 0.11.0@5d7fa4f, from The PHP Foundation
You are running PHP 8.4.6
Target PHP installation: 8.4.6 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php8.4)
Downloading the latest nightly release.
✅ Verified the new PIE version
✅ PIE has been upgraded to nightly
icense information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Util;

use Composer\XdebugHandler\XdebugHandler;

/**
 * Provides ini file location functions that work with and without a restart.
 * When the process has restarted it uses a tmp ini and stores the original
 * ini locations in an environment variable.
 *
 * @author John Stevenson <john-stevenson@blueyonder.co.uk>
 */
class IniHelper
{
    /**
     * Returns an array of php.ini locations with at least one entry
     *
     * The equivalent of calling php_ini_loaded_file then php_ini_scanned_files.
     * The loaded ini location is the first entry and may be empty.
     *
     * @return string[]
     */
    public static function getAll(): array
    {
        return XdebugHandler::getAllIniFiles();
    }

    /**
     * Describes the location of the loaded php.ini file(s)
     */
    public static function getMessage(): string
    {
        $paths = self::getAll();

        if (empty($paths[0])) {
            array_shift($paths);
        }

        $ini = array_shift($paths);

        if (empty($ini)) {
            return 'A php.ini file does not exist. You will have to create one.';
        }

        if (!ePHP Fatal error:  Uncaught Error: Class "Symfony\Component\Console\Event\ConsoleTerminateEvent" not found in phar:///home/james/workspace/phpf/pie/pie.phar/vendor/symfony/console/Application.php:1110
Stack trace:
#0 phar:///home/james/workspace/phpf/pie/pie.phar/vendor/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#1 phar:///home/james/workspace/phpf/pie/pie.phar/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#2 phar:///home/james/workspace/phpf/pie/pie.phar/bin/pie(53): Symfony\Component\Console\Application->run()
#3 /home/james/workspace/phpf/pie/pie.phar(15): require('...')
#4 {main}
  thrown in phar:///home/james/workspace/phpf/pie/pie.phar/vendor/symfony/console/Application.php on line 1110

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.