Skip to content

Pie mixing up two extension packages that use the same extension name #596

@hackel

Description

@hackel

What are you trying to do?
I discovered this edge case by accident while looking at the new pie-extensions/redis package. After downloading it, I decided I didn't want to install a random, as of yet untrusted, binary, so I installed the upstream phpredis/phpredis package instead, and that's where the fun began. The following is reproducible for me.

What platform, and PIE version are you using?
Amazon Linux 2023

🥧 PHP Installer for Extensions (PIE) 1.4.2, from The PHP Foundation
You are running PHP 8.4.19
Target PHP installation: 8.4.19 nts, on Linux/OSX/etc x86_64 (from /usr/bin/php)

Steps to reproduce the issue

  1. pie download -v pie-extensions/redis
  2. pie install -v phpredis/phpredis
  3. pie uninstall -v pie-extensions/redis
  4. pie uninstall -v phpredis/phpredis

What do you expect to happen?

  1. pie-extensions/redis source downloaded to my home directory (only contains a binary)
  2. phpredis/phpredis source downloaded to my home directory, compiled, and binary installed, without affecting the pie-extensions/redis download
  3. redis.so from pie-extensions/redis should be deleted from my home directory with no errors, without touching the phpredis/phpredis installation
  4. phpredis/phpredis extension should be disabled, binary deleted from /usr/lib64/php8.4/modules, and source deleted from my home directory, with no errors

What is actually happening

  1. Working as expected
    • Extension extracted to: .config/pie/php8.4_35840a531d0d3687d23bdc9551cc8a03/vendor/pie-extensions/redis/redis.so (2617232 bytes)
  2. Extension is downloaded and compiled
    • Extension installed to: /usr/lib64/php8.4/modules/redis.so (2555792 bytes)
    • pie show now shows the other package as being loaded:
      Loaded PIE extensions:
        redis:6.3.0 (from 🥧 pie-extensions/redis:6.3.0)
      
    • The redis.so binary from pie-extensions/redis has been deleted from .config/pie/php8.4_35840a531d0d3687d23bdc9551cc8a03/vendor/pie-extensions/redis/
    • The phpredis/phpredis source was deleted after installation (perhaps this is intentional?)
  3. "Uninstall of pie-extensions/redis failed: PIE metadata was missing for package pie-extensions/redis. Missing metadata keys: pie-installed-binary, pie-installed-binary-checksum"
    • pie show now indicates:
      Loaded PIE extensions:
      (none)

      PIE packages not loaded:
      These extensions were installed with PIE but are not currently enabled.

      • pie-extensions/redis:6.3.0
    • redis.so from phpredis/phpredis still installed at /usr/lib64/php8.4/modules/redis.so

  4. No package found: phpredis/phpredis
    • phpredis/phpredis is still present in .config/pie/php8.4_35840a531d0d3687d23bdc9551cc8a03/pie.json:
      {
          "require": {
              "phpredis/phpredis": "^6.3"
          }
      }
      

Complete logs/output
This is from step 3: pie uninstall -v pie-extensions/redis:

    - Loading composer repositories with package information
      Updating dependencies
      Lock file operations: 0 installs, 0 updates, 1 removal
        - Removing pie-extensions/redis (6.3.0)
      Writing lock file
      Installing dependencies from lock file
      Package operations: 0 installs, 0 updates, 1 removal
        - Removing pie-extensions/redis (6.3.0)
      INI file "/etc/php.d/60-redis.ini" was updated to remove the extension.
          Uninstall of pie-extensions/redis failed
      In PackageMetadataMissing.php line 26:
        [Php\Pie\Installing\PackageMetadataMissing]
        PIE metadata was missing for package pie-extensions/redis. Missing metadata keys: pie-installed-binary, pie-installed-binary-checksum
      Exception trace:
        at phar:///usr/local/bin/pie/src/Installing/PackageMetadataMissing.php:26
       Php\Pie\Installing\PackageMetadataMissing::duringUninstall() at phar:///usr/local/bin/pie/src/Installing/UninstallUsingUnlink.php:30
       Php\Pie\Installing\UninstallUsingUnlink->__invoke() at phar:///usr/local/bin/pie/src/ComposerIntegration/UninstallProcess.php:55
       Php\Pie\ComposerIntegration\UninstallProcess->__invoke() at phar:///usr/local/bin/pie/src/ComposerIntegration/PiePackageInstaller.php:106
       Php\Pie\ComposerIntegration\PiePackageInstaller->{closure:Php\Pie\ComposerIntegration\PiePackageInstaller::uninstall():81}() at phar:///usr/local/bin/pie/vendor/react/promise/src/Internal/FulfilledPromise.php:47
       React\Promise\Internal\FulfilledPromise->then() at phar:///usr/local/bin/pie/src/ComposerIntegration/PiePackageInstaller.php:81
       Php\Pie\ComposerIntegration\PiePackageInstaller->uninstall() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:525
       Composer\Installer\InstallationManager->uninstall() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:382
       Composer\Installer\InstallationManager->{closure:Composer\Installer\InstallationManager::executeBatch():381}() at phar:///usr/local/bin/pie/vendor/react/promise/src/Internal/FulfilledPromise.php:47
       React\Promise\Internal\FulfilledPromise->then() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:381
       Composer\Installer\InstallationManager->executeBatch() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:323
       Composer\Installer\InstallationManager->downloadAndExecuteBatch() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer/InstallationManager.php:221
       Composer\Installer\InstallationManager->execute() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer.php:847
       Composer\Installer->doInstall() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer.php:657
       Composer\Installer->doUpdate() at phar:///usr/local/bin/pie/vendor/composer/composer/src/Composer/Installer.php:302
       Composer\Installer->run() at phar:///usr/local/bin/pie/src/ComposerIntegration/ComposerIntegrationHandler.php:138
       Php\Pie\ComposerIntegration\ComposerIntegrationHandler->runUninstall() at phar:///usr/local/bin/pie/src/Command/UninstallCommand.php:98
       Php\Pie\Command\UninstallCommand->execute() at phar:///usr/local/bin/pie/vendor/symfony/console/Command/Command.php:326
       Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/pie/vendor/symfony/console/Application.php:1121
       Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/pie/vendor/symfony/console/Application.php:324
       Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/pie/vendor/symfony/console/Application.php:175
       Symfony\Component\Console\Application->run() at phar:///usr/local/bin/pie/bin/pie:62
       require() at /usr/local/bin/pie:16

      uninstall [--with-php-config WITH-PHP-CONFIG] [--with-php-path WITH-PHP-PATH] [--with-phpize-path WITH-PHPIZE-PATH] [--no-cache] [--] <package-name>

Anything else?
In the end, I just deleted my .config/pie directory and started over. Everything works great if I stick to a single redis package.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingbug-confirmedMaintainers could reproduce the issue and will investigatemaintainer investigatingThis ticket is being investigated by maintainers. Please check with us before contributing PRs etc!

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions