読者です 読者をやめる 読者になる 読者になる

composer removeとかupdateとかできない

composer

What?

  • Class hogehoge not foundと表示されて、composerでライブラリ操作ができなくなる
$ composer remove illuminate/html
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "laravel/framework" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Removing illuminate/html (v5.0.0)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize


  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Class 'Collective\HTML\HtmlServiceProvider' not found


Script php artisan optimize handling the post-update-cmd event returned with error code 1

Removal failed, reverting ./composer.json to its original content.

How to

  • config/app.phpprovidersに使っていないものが書いてあるので、消す
'providers' => [
    ...
    // Collective\HTML\HtmlServiceProvider::class,
    ...
],
  • おっけー
$ composer remove illuminate/html
Package "illuminate/html" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled services file has been removed.
$ composer require laravelcollective/html
Using version ^5.4 for laravelcollective/html
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravelcollective/html (v5.4.1) Downloading: 100%
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled services file has been removed.

How to その2

  • php artisan optimizeでコケてるので、--no-scripts オプションで実行後スクリプトを実行させない
$ composer remove --no-scripts laravelcollective/html
Package "laravelcollective/html" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
$ composer require --no-scripts laravelcollective/html
Using version ^5.4 for laravelcollective/html
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files