我通过执行composer require phpspec/phpspec
在代码库根目录下通过composer安装了phpspec。我想运行它而不每次都给它加上前缀vendor/bin
,但是我也不想将其添加到PATH
中,所以我首先在全局安装了composer global require phpspec/phpspec
(两个版本都是相同),并使用export PATH=$PATH:~/.composer/vendor/bin
添加到路径(我在MacOS Catalina上)。
现在,我可以从代码库根目录运行phpspec
,并且确实可以运行。我可以运行phpspec describe xxx
来创建文件并可以正常工作,但是执行phpspec run
却失败了:
✘ Fatal error happened while executing the following
Uncaught TypeError: Argument 2 passed to Symfony\Component\EventDispatcher\EventDispatcher::dispatch() must be an instance of Symfony\Component\EventDispatcher\Event or null, string given, called in /Users/.../.composer/vendor/phpspec/phpspec/src/PhpSpec/Util/DispatchTrait.php on line 22 and defined in /Users/.../.composer/vendor/symfony/event-dispatcher/EventDispatcher.php:37
Stack trace:
#0 /Users/.../.composer/vendor/phpspec/phpspec/src/PhpSpec/Util/DispatchTrait.php(22): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(PhpSpec\Event\SuiteEvent), 'beforeSuite')
#1 /Users/.../.composer/vendor/phpspec/phpspec/src/PhpSpec/Runner/SuiteRunner.php(52): PhpSpec\Runner\SuiteRunner->dispatch(Object(Symfony\Component\EventDispatcher\EventDispatcher), Object(PhpSpec\Event\SuiteEvent), 'beforeSuite')
#2 /Users/.../.composer/vendor/phpspec/phpspec/src/PhpSpec/Console/Command/RunCommand.php(178): PhpSpec\Runner\SuiteRunner->run(Object(PhpSpec\Loader\Suite))
#3 /Users/.../.composer/ven in /Users/.../.composer/vendor/symfony/event-dispatcher/EventDispatcher.php on line 37
但是运行vendor/bin/phpspec run
还是可以的。
这里可能是什么错误?