0
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 updateでメモリが足りない場合の対策

Posted at

Laravelで開発をしていて、composerでライブラリを導入したいときにメモリが足りなくて怒られたので備忘録として残します。

発生事象

Allowed memory size of 1610612736 bytes exhausted...として怒られます。
意味としては、割り当ててあるメモリを使い果たしたよってことです。

$ composer require laravel/socialite

Using version ^5.1 for laravel/socialite
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Fatal error: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223

Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.

対策

以下のコマンドを実行することで、解消できました。

COMPOSER_MEMORY_LIMIT=-1で、一時的にメモリの制限を解除しています。
which composerで、composerのパスを持ってきて渡しています。

$ COMPOSER_MEMORY_LIMIT=-1 $(which composer) require laravel/socialite

Using version ^5.1 for laravel/socialite
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
73 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

参考

composer update でメモリオーバーする場合の対策
https://qiita.com/ucan-lab/items/af39b71c6eb304ddf696

0
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
0
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?