Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away