cancel
Showing results for 
Search instead for 
Did you mean: 

Composer problem

SOLVED

Composer problem

When I run any composer command I get this error:

 

PHP Fatal error: Uncaught Error: Undefined class constant 'PRE_COMMAND_RUN' in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php:63
Stack trace:
#0 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(378): Laminas\DependencyPlugin\DependencyRewriterPlugin::getSubscribedEvents()
#1 /usr/share/php/Composer/Plugin/PluginManager.php(239): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#4 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#5 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginM in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php on line 63

Fatal error: Uncaught Error: Undefined class constant 'PRE_COMMAND_RUN' in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php:63
Stack trace:
#0 /usr/share/php/Composer/EventDispatcher/EventDispatcher.php(378): Laminas\DependencyPlugin\DependencyRewriterPlugin::getSubscribedEvents()
#1 /usr/share/php/Composer/Plugin/PluginManager.php(239): Composer\EventDispatcher\EventDispatcher->addSubscriber(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#2 /usr/share/php/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(Laminas\DependencyPlugin\DependencyRewriterPlugin))
#3 /usr/share/php/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
#4 /usr/share/php/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
#5 /usr/share/php/Composer/Factory.php(384): Composer\Plugin\PluginM in /var/www/drug-mart.ca/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPlugin.php on line 63

 

Please HELP!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Composer problem

Needed to reinstall composer from version 1.6 to 1.10

View solution in original post

2 REPLIES 2

Re: Composer problem

Needed to reinstall composer from version 1.6 to 1.10

Re: Composer problem

I'd be glad to help you with the Composer error "Undefined class constant 'PRE_COMMAND_RUN'".

 

Understanding the Error:

 

This error indicates that the laminas/laminas-dependency-plugin library you're using is referencing a constant named PRE_COMMAND_RUN which isn't defined in your current Composer version. This constant was likely introduced in a newer version of Composer.

Potential Causes:

  • Outdated Composer: The most probable cause is an outdated Composer version. The PRE_COMMAND_RUN constant was likely added in a later release.
  • Conflicting Versions: There might be a version mismatch between laminas/laminas-dependency-plugin and your Composer. An older plugin version might be expecting a newer Composer constant.

Solutions:

  1. Upgrade Composer:

    • Run composer --version to check your current version.
    • If it's older than 1.9 or 1.10 (depending on sources), update it:
      Bash
      composer self-update
  2. Clear Composer Cache:

    • If upgrading doesn't resolve the issue, clear the cache:
      Bash
      composer clearcache
  3. Check Plugin Version:

    • If the above steps don't work, consider the plugin version:
      • Check your composer.json for the laminas/laminas-dependency-plugin version.
      • If it's an older version, consider updating it to a compatible version that might not rely on the missing constant. You can find compatible versions on Packagist (packagist dot org).

Additional Tips:

  • Review Recent Changes: If you recently made changes to your project or dependencies, revert them temporarily to see if they introduced the conflict.
  • Magento Context: If you're working with Magento, note that Magento 2.3.5 and later versions typically require a compatible Composer version. Consider checking Magento documentation or community forums for specific requirements related to your Magento version.

If the issue persists after trying these solutions, provide more details:

  • Specific Composer version
  • Exact error message (if different from the provided one)
  • The type of project you're working on (e.g., Magento)
  • Any recent changes made to your project or dependencies

By following these steps and providing additional information if needed, you should be able to resolve the Composer error and run your drugtests composer commands successfully.