Magento 2

After running: grunt clean and then grunt exec:myTheme I get the following

error: >> [InvalidArgumentException]

There are no commands defined in the "dev:source-theme" namespace.
Exited with code: 1.

Warning: Task "exec:myTheme" failed. Use --force to continue.

Anyone know what this could relate to?

4 Answers 4


I have the same issue and I solved it by removing the 2 folders below :

  • /var/di
  • /var/generation
  • You don't necessarily need to remove these directories. Just set 777 permission to var folder. Should work fine. Jun 9, 2016 at 9:23
  • php bin/magento setup:static-content:deploy and then clearing all caches made it work for me
    – dlicheva
    Dec 6, 2016 at 14:39

If you are using MAMP easiest way to get this working is by editing dev/tools/grunt/configs/combo.js

find line:

command = command + 'php bin/magento dev:source-theme:deploy ' +

and replace with your local version of PHP eg:

command = command + '/Applications/MAMP/bin/php/php7.3.21/bin/php bin/magento dev:source-theme:deploy ' +

to find your path to php do:

which php

Heres a further explanation:



I had this issue. It arose after I installed a Magento Theme into a subfolder of the root directory of my virtual host (i.e. /Applications/MAMP/htdocs/magento2/mycustomtheme_magento2_quickstart). I then proceeded to run grunt clean followed by grunt exec:mycustomtheme within the theme sub-directory, and got the error There are no commands defined in the "dev:source-theme" namespace..

I tried removing the /var/generation sub-folder but this did not solve the problem (I did not have a /var/di sub-folder).

I eventually solved it by simply opened my web browser (i.e. Chrome) and went to the subfolder address of my custom theme using my virtual host (i.e. http://local.magento2:8888/mycustomtheme_magento2_quickstart/).

It opened the Magento Installer page. I went through the steps to set it up (i.e. Step 1: Readiness Check, etc).

After it was setup I was able to run grunt clean followed by grunt exec:mycustomtheme without that error.


grunt:exec command relies on php bin/magento dev:source-theme:deploy

if the command would not success There are no commands defined in the "dev:source-theme" namespace can appear as well.

In my case, after playing with local environment bit too much I've had to replace default php version in CLI from 5.6 to 7.0 for Magento 2.2.

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.