diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 826f41c86..466611402 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -26,6 +26,7 @@ use Composer\DependencyResolver\Operation\InstallOperation; use Composer\Package\Version\VersionSelector; use Composer\Package\AliasPackage; use Composer\Pcre\Preg; +use Composer\Plugin\PluginBlockedException; use Composer\Repository\RepositoryFactory; use Composer\Repository\CompositeRepository; use Composer\Repository\PlatformRepository; @@ -268,9 +269,15 @@ EOT $installer->disablePlugins(); } - $status = $installer->run(); - if (0 !== $status) { - return $status; + try { + $status = $installer->run(); + if (0 !== $status) { + return $status; + } + } catch (PluginBlockedException $e) { + $io->writeError('Hint: To allow running the config command recommended below before dependencies are installed, run create-project with --no-install.'); + $io->writeError('You can then cd into '.getcwd().', configure allow-plugins, and finally run a composer install to complete the process.'); + throw $e; } } diff --git a/src/Composer/Plugin/PluginBlockedException.php b/src/Composer/Plugin/PluginBlockedException.php new file mode 100644 index 000000000..04a8db005 --- /dev/null +++ b/src/Composer/Plugin/PluginBlockedException.php @@ -0,0 +1,19 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Plugin; + +use UnexpectedValueException; + +class PluginBlockedException extends UnexpectedValueException +{ +} diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index fdf50c4d4..dc6dc8d11 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -765,7 +765,7 @@ class PluginManager } } - throw new \UnexpectedValueException( + throw new PluginBlockedException( $package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe.'.PHP_EOL. 'You can run "composer '.($isGlobalPlugin ? 'global ' : '').'config --no-plugins allow-plugins.'.$package.' [true|false]" to enable it (true) or disable it explicitly and suppress this exception (false)'.PHP_EOL. 'See https://getcomposer.org/allow-plugins'