I am trying to set the deploy mode on an M2 instance to Production from Developer. On my local environment however I keep getting the error message:

Command returned non-zero exit code:
'/Applications/MAMP/bin/php/php7.0.10/bin/php -f /Applications/MAMP/htdocs/JWM2/bin/magento setup:di:compile'

When it errors and escapes back to the prompt, I type echo $? and simply get 1 returned back.

On the recommendation of another post, I have tried increasing the php memory_limit which didn't help. I have also tried running the setup:di:compile command separately, but this completed successfully, however there were some errors relating to the dependancies already existing in context objects for a couple of modules.

When I try to change the deploy mode on the production server, the issue lies with the setup:static-content:deploy part of the process with the issue being with the Magento Backend theme.

If I add the flag --skip-compilation to the deploy:mode:set production then it slides in to the correct mode without problem.

Has anyone got any ideas how I can make this work with compilation?

1 Answer 1


If you run

/Applications/MAMP/bin/php/php7.0.10/bin/php -f /Applications/MAMP/htdocs/JWM2/bin/magento -vvv setup:di:compile

it will show you what problem do you have

  • Unfortunately, this didn't tell me anything new, I'm not sure if -vvv is used in all of the bin/.magento scripts. Nov 15, 2016 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.