1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

composer requireで could not delete エラーが出てきたときの解消法

Posted at

*WindowsPCでvagrantで仮想環境を立てて、lamp環境を使っています

#背景
doctrine/dbalのライブラリが必要になったのでインストールすることに。
composer require doctrine/dbalを実行

[vagrant@localhost testproject]$ composer require doctrine/dbal
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^3.1 for doctrine/dbal
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
^[cPackage operations: 5 installs, 0 updates, 0 removals
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
  - Installing composer/package-versions-deprecated (1.11.99.1): Loading from cache
Plugin installation failed (include(/var/www/html/testproject/vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php): failed to open stream: No such file or directory), rolling back
  - Removing composer/package-versions-deprecated (1.11.99.1)

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


  [RuntimeException]
  Could not delete /var/www/html/testproject/vendor/composer/package-versions-deprecated/src/PackageVersions:


require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] 

上記のような Could not delete エラー発生

#解決法
まずは手早く結論から。。。!

① composer require composer/package-versions-deprecated --dev --prefer-source の実行

参考:https://github.com/barryvdh/laravel-ide-helper/issues/1135

[vagrant@localhost testproject]$ composer require composer/package-versions-deprecated --dev --prefer-source
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Using version 1.11.99.1 for composer/package-versions-deprecated
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing composer/package-versions-deprecated (1.11.99.1): Cloning 7413f0b55a
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
62 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

↑このコマンドを実行したことによりとりあえず第一段階はOK!

やってみたこと

元々のエラーで、
` - Installing composer/package-versions-deprecated (1.11.99.1): Loading from cache
Plugin installation failed (include(/var/www/html/testproject/vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php): failed to open stream: No such file or directory), rolling back

  • Removing composer/package-versions-deprecated (1.11.99.1) こうでてたのでおそらくこのcomposer/package-versions-deprecated`は現状とりあえずなさそうだと判断し、
    入れてみることにした

いざ実行

[vagrant@localhost testproject]$ composer require composer/package-versions-deprecated                                                    Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Using version 1.11.99.1 for composer/package-versions-deprecated
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing composer/package-versions-deprecated (1.11.99.1): Loading from cache
Plugin installation failed (include(/var/www/html/testproject/vendor/composer/package-versions-deprecated/src/PackageVersions/Installer.php): failed to open stream: No such file or directory), rolling back
  - Removing composer/package-versions-deprecated (1.11.99.1)

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


  [RuntimeException]
  Could not delete /var/www/html/testproject/vendor/composer/package-versions-deprecated/src/PackageVersions:


require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

すると同じようなエラーが出る。
しばらくググっていたら参考に取り上げた記事を発見(https://github.com/barryvdh/laravel-ide-helper/issues/1135)
--dev --prefer-sourceこれを付けたことにより無事インストール完了。(この意味は分からないが。。。)

② 再度 composer require doctrine/dbal の実行

[vagrant@localhost testproject]$ composer require doctrine/dbal
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Using version ^3.1 for doctrine/dbal
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing doctrine/event-manager (1.1.1): Downloading (100%)
  - Installing doctrine/deprecations (v0.5.3): Downloading (100%)
  - Installing doctrine/cache (1.11.0): Downloading (100%)
  - Installing doctrine/dbal (3.1.0): Downloading (100%)
doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
65 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

①つめのコマンド実行によってエラーが潰せたのか、
Could not delete のエラーもでることなく無事インストール完了!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?