LoginSignup
17
14

More than 5 years have passed since last update.

WP-CLI でメモリ不足のエラーが出る時の対処法

Last updated at Posted at 2016-12-19

WP-CLI のパッケージコマンド関連のサブコマンド、たとえば wp package install とか wp package update では、composer を呼び出しているので、以下のようにメモリ不足のエラーが出ることがあります。

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes) in ...

そんな時は、以下のようにするといいみたい。

$ php -d memory_limit=-1 /usr/local/bin/wp

たまたまそういう事案を目にした同じ日に WP-CLI の開発チームの方で話題になってたのでメモ。

追記

頻繁にこのエラーが出る場合には、~/.bash_profile に以下のように書いておくといいかも。

alias wp="php -d memory_limit=-1 /usr/local/bin/wp"

追記(2016/12/23)

@ayato さんから指摘をいただいて調べたのですが、Homebrew でインストールした場合の WP-CLI はシェルスクリプト経由で呼び出されているため、以下のようにする必要があります。

(以下はbashの場合)

$ WP_CLI_PHP_ARGS='-d memory_limit=-1' wp

ただし僕の環境では、デフォルトが -1 でした。

Daniel: WP_CLI_PHP_ARGS is only applicable when calling the bash starter script. If you've installed the Phar, you can php directly
Miya: Which is the homebrew verion? Japanese user who install from homebrew asked me that php -d memory_limit=-1 /usr/local/bin/wp wasn't seem to be working for him. Is it right?
Daniel: homebrew is Phar

リード開発者のダニエルちゃんも勘違いしてたみたい。。。笑

17
14
6

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
17
14