Magento – Class ‘Magento\Setup\Mvc\Bootstrap\InitParamListener’ not found when running CLI

climagento-2.1

I have a VM running Magento 2 with the sample data that was installed not using composer – I grabbed the latest version from the Magento site). The site itself runs fine, but when I try to run anything for the command line, I get this error:

PHP Fatal error:  Uncaught Error: Class 'Magento\Setup\Mvc\Bootstrap\InitParamListener' not found in /var/www/html/public/setup/config/application.config.php:24
Stack trace:
#0 /var/www/html/public/vendor/magento/framework/Console/Cli.php(57): require()
#1 /var/www/html/public/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI')
#2 {main}
  thrown in /var/www/html/public/setup/config/application.config.php on line 24

I built the VM on another machine using build scripts, and then used those to build it on this machine, and it worked for a bit, but I suspect I left something out of source control that would be causing this.

Best Answer

I got a very similar issue with the following error;

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Magento\Setup\Mvc\Bootstrap\InitParamListener

I was able to solve this by deleting the contents of vendor and then re-running composer install