Error when run command grunt:exec Magento 2.2.0 . Please see screenshot !!!
Preconditions
Magento 2.2.0
PHP 7.1
Steps to reproduce
1) Setup theme on Magento 2.2.0 environment
2) setup grunt , setup node_modules & add path theme in theme.js .
3) Run grunt:exec
Expected result
Run grunt exec need to successful
Actual result
grunt appearing error : [InvalidArgumentException] >> Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/Emthemes/laparis/en_US/css/styles-m.less'
Screenshot
https://prnt.sc/han7jt]
https://prnt.sc/han8wg
@yesman2104, thank you for your report.
We've created internal ticket(s) MAGETWO-84356 to track progress on the issue.
Problem not in grunt:exec
. Grunt command executes dev:source-theme:deploy
command and put arguments from config. On first screenshot we can see that arguments correctly provided from grunt, but Exception says that file not exist. Are you sure that style-m.less
file really exist under path from config?
_(My version of the issue is solved, look at the bottom)_
I have a similar issue, but instead of executing grunt:exec, I am executing the command
bin/magento dev:source-theme:deploy --type="less" --locale="en_US" --area="frontend" --theme="Vendor/Theme" css/styles
directly (as referenced by http://devdocs.magento.com/guides/v2.1/config-guide/cli/config-cli-subcommands-less-sass.html) and I get the same type of error message:
[InvalidArgumentException]
Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/Vendor/Theme/en_US/css/styles.less'
My /dev/tools/grunt/configs/themes.js
file include
module.exports = {
theme: {
area: 'frontend',
name: 'Vendor/Theme',
locale: 'en_US',
files: [
'css/styles'
],
dsl: 'less'
}
}
and the file styles.less
exist in the folder /app/design/frontend/Vendor/Theme/web/css/
.
(You may notice that the error message prints a reference to frontend/Vendor/Theme/en_US/css/styles.less
, which in itself is strange, since it references a .less
file, which should be the source file, while the target file should be .css
file, but the directory is the intended target folder)
I stumbled across this command when I really was searching for a solution to an issue I have with the command setup:static-content:deploy
that fails due to missing compilated files in the static folder, but I have a suspicion that the issues are connected, possibly even dependent on one another.
Any help would be very much appreciated.
EDIT: Added a reference to a documentation of the given command, and a parenthesis commenting the seemingly strange reference to the .less file in the error message.
SOLVED: I found the cause of the issue for me. I used a capital letter for the theme folder. When I changed it to lowercase, everything worked just fine. I leave my comment up here, if anyone else stumbles upon it by the same reason I did, and could be helped by my mistake.
Please help me !!!!
@yesman2104: as omiroshnichenko was asking, are you sure the file exist under path from config?
@yesman2104 Also, can you try to run directly bin/magento command and show result?
bin/magento dev:source-theme:deploy --type="less" --locale="en_US" --area="frontend" --theme="Vendor/Theme" css/styles
I've got the same issue, running magento 2.2.0, having everything configured as it worked before.
Created a child theme of magento luma inside /app/design/frontend.
When i use grunt exec:theme, i get the same error of missing files. Have also tried the suggestion of @omiroshnichenko.
Any other options? Or is this functionality simply not working in 2.2.0? Does anybody have a patch / workaround?
EDIT: Downgraded magento back to 2.0.17, and grunt is working as it should..
EDIT: got it working on 2.2.2!
Found the problem: we had a namespace with a digit in it. Also, the theme directory was: theme-themename instead of themename.
Theme path we had: 42functions/theme-clientname
Theme path that works: xlii/clientname
So, verify if you have a valid name for your theme. For me everything else was working normally.. except for grunt.
I'm having no such luck with mine. My vendor name has digits in it (lvl99/test
), but it's not the first character (and I've tried it without digits to no avail).
This is the output I get when running grunt exec:test
:
Running "exec:test" (exec) task
Running "clean:test" (clean) task
>> 302 paths cleaned.
Done.
Execution Time (2018-02-14 12:08:12 UTC)
loading tasks 44ms โโโโโโโโโโ 28%
loading grunt-contrib-clean 2ms โ 1%
clean:test 112ms โโโโโโโโโโโโโโโโโโโโโโโโ 70%
Total 159ms
Processed Area: frontend, Locale: en_US, Theme: lvl99/test, File type: less.
-> css/styles-m.less
-> css/styles-l.less
>>
>>
>> [InvalidArgumentException]
>> Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/lvl99/test/en_US/css/extra-styles.less'
>> dev:source-theme:deploy [--type TYPE] [--locale LOCALE] [--area AREA] [--theme THEME] [--] [<file>]...
>>
>> Exited with code: 1.
>> Error executing child process: Error: Process exited with code 1.
Warning: Task "exec:test" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-02-14 12:08:11 UTC)
exec:test 13.2s โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 100%
Total 13.3s
And the output I get running ./bin/magento dev:source-theme:deploy --type="less" --locale="en_US" --area="frontend" --theme="lvl99/test" css/extra-styles
:
Processed Area: frontend, Locale: en_US, Theme: lvl99/test, File type: less.
[InvalidArgumentException]
Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/lvl99/test/en_US/css/extra-styles.less'
dev:source-theme:deploy [--type TYPE] [--locale LOCALE] [--area AREA] [--theme THEME] [--] [<file>]...
This is my dev/tools/grunt/configs/themes.js
file:
module.exports = {
blank: {
area: 'frontend',
name: 'Magento/blank',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l',
'css/email',
'css/email-inline'
],
dsl: 'less'
},
luma: {
area: 'frontend',
name: 'Magento/luma',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
},
backend: {
area: 'adminhtml',
name: 'Magento/backend',
locale: 'en_US',
files: [
'css/styles-old',
'css/styles'
],
dsl: 'less'
},
test: {
area: 'frontend',
name: 'lvl99/test',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l',
'css/extra-styles'
],
dsl: 'less'
}
};
My theme is set to inherit from Magento/blank. The folder structure I have for my theme is:
lvl99/
test/
web/
css/
source/
_theme.less
_extra-styles.less
... # and the rest
I have the same issue in 2.2.4. Also tried everything I have read on this page i.e. folder renaming. Files do exist in the location and there is _theme.less in source too
/var/www/html/magento2/app/design/frontend/parity/lapsi/web/css$ ls
source styles.css styles-l.less styles-m.less
Grunt config local-themes.js below (tried with standard themes.js - no change)
`/**
* Copyright ยฉ Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
'use strict';
/**
* Define Themes
*
* area: area, one of (frontend|adminhtml|doc),
* name: theme name in format Vendor/theme-name,
* locale: locale,
* files: [
* 'css/styles-m',
* 'css/styles-l'
* ],
* dsl: dynamic stylesheet language (less|sass)
*
*/
module.exports = {
blank: {
area: 'frontend',
name: 'Magento/blank',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l',
'css/email',
'css/email-inline'
],
dsl: 'less'
},
luma: {
area: 'frontend',
name: 'Magento/luma',
locale: 'en_US',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
},
backend: {
area: 'adminhtml',
name: 'Magento/backend',
locale: 'en_US',
files: [
'css/styles-old',
'css/styles'
],
dsl: 'less'
},
lapsi: {
area: 'frontend',
name: 'parity/lapsi',
locale: 'en_GB',
files: [
'css/styles-m',
'css/styles-l'
],
dsl: 'less'
}
};`
sudo grunt exec:lapsi --verbose
Processed Area: frontend, Locale: en_GB, Theme: parity/lapsi, File type: less.
>>
>> [InvalidArgumentException]
>> Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/parity/lapsi/en_GB/css/styles-m.less'
>>
>>
>> dev:source-theme:deploy [--type TYPE] [--locale LOCALE] [--area AREA] [--theme THEME] [--] [<file>]...
>> Exited with code: 1.
>> Error executing child process: Error: Process exited with code 1.
Warning: Task "exec:lapsi" failed. Use --force to continue.
Aborted due to warnings.
Execution Time (2018-06-21 22:36:04 UTC)
loading tasks 65ms โโ 1%
loading grunt-exec 4ms 0%
exec:lapsi 4.6s โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 99%
Total 4.6s
Any help would be greatly appreciated...Thanks
any update on this issue. I looked everywhere ...
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!
@riconeitzel I tried, but that did not work for me.
What worked for me was to downgrade to node v8.12.0 instead of node V 10.10.0,.
I hope that this helps for other people.
After installing node v8 everything is running smoothly
The v10 vs v8 issue has a different error message:
>> /usr/local/Cellar/node/10.10.0/bin/node: bad option: --force
to fix that use node <= v8
I have no digits in theme name, version of node.js is 8.9.3, the theme exists in content > themes. And I had this issue.
What helped
I just restart docker.
Can you please copy and paste the full error message?
Thanks :-)
Processed Area: frontend, Locale: en_US, Theme: Custom/Test, File type: less.
[InvalidArgumentException]
Verify entered values of the argument and options. Unable to resolve the source file for 'frontend/Custom/Test/en_US/css/extend.less'
dev:source-theme:deploy [--type TYPE] [--locale LOCALE] [--area AREA] [--theme THEME] [--] []...
Exited with code: 1.
Error executing child process: Error: Process exited with code 1.
Warning: Task "exec:Test" failed. Use --force to continue.
Try this command - without 'css/styles'
bin/magento dev:source-theme:deploy --type="less" --locale="en_US" --area="frontend" --theme="Vendor/Theme"
This error happens for multiple reasons, but probably the most annoying and most frequent relates to the fact that Magento2 attempts to validate themes.
If a theme exists in the database, but is not physically available in the filesystem at the time the magento setup:install
command is run, Magento2 will set it as a "virtual" theme. Once a theme is set as virtual, it is never unset by Magento2. It will forever be virtual until it is manually reset in the database. To reset the theme, go to the theme
table, and set the type
field to 0
, and re-associate the theme with any parent_id
. A theme with a type
of 1
has been set to virtual.
This problem will provide a stack trace like the following:
Fatal error: Uncaught Error: Call to a member function getId() on null in /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php:751 Stack trace:
#0 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(684): Magento\Framework\View\Model\Layout\Merge->_getPhysicalTheme(Object(Magento\Theme\Model\Theme))
#1 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(633): Magento\Framework\View\Model\Layout\Merge->_loadFileLayoutUpdatesXml()
#2 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/var/generation/LinusShops/Common/Model/Layout/Merge/Interceptor.php(245): Magento\Framework\View\Model\Layout\Merge->getFileLayoutUpdatesXml()
#3 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(527): LinusShops\Common\Model\Layout\Merge\Intercep in /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php on line 751
This can all be traced through the _getPhysicalTheme
method. It's ridiculous that this even occurs. The physical presence of a theme should just break the site in a very expected way: that is, the frontend just doesn't appear. Don't try to be clever and modify the DB. Magento design decisions never cease to amaze me.
You can imagine what this means for anyone migrating their databases to a new host. For example, you import your DB dump to a new host. Once the DB is migrated, you then issue the standard magento setup:install
command. Guess what? Now your theme will never build. Why? Because the theme itself did not physically exist on the filesystem at the time of the install. What is supposed to come first, Magento--the chicken or the egg?
This works for me:
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!
@riconeitzel Can confirm that! ๐
The v10 vs v8 issue has a different error message:
>> /usr/local/Cellar/node/10.10.0/bin/node: bad option: --force
to fix that use node <= v8
@riconeitzel I had the same v10 vs v8 issue, it looks like removing --force
in grunt/configs/combo.js is working but I'm worried it could mess something else.
Do you see any reason to keep the --force
option?
This error happens for multiple reasons, but probably the most annoying and most frequent relates to the fact that Magento2 attempts to validate themes.
Explanation
If a theme exists in the database, but is not physically available in the filesystem at the time the
magento setup:install
command is run, Magento2 will set it as a "virtual" theme. Once a theme is set as virtual, it is never unset by Magento2. It will forever be virtual until it is manually reset in the database. To reset the theme, go to thetheme
table, and set thetype
field to0
, and re-associate the theme with anyparent_id
. A theme with atype
of1
has been set to virtual.This problem will provide a stack trace like the following:
Fatal error: Uncaught Error: Call to a member function getId() on null in /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php:751 Stack trace: #0 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(684): Magento\Framework\View\Model\Layout\Merge->_getPhysicalTheme(Object(Magento\Theme\Model\Theme)) #1 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(633): Magento\Framework\View\Model\Layout\Merge->_loadFileLayoutUpdatesXml() #2 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/var/generation/LinusShops/Common/Model/Layout/Merge/Interceptor.php(245): Magento\Framework\View\Model\Layout\Merge->getFileLayoutUpdatesXml() #3 /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php(527): LinusShops\Common\Model\Layout\Merge\Intercep in /vagrant/sites/phoenix.vagrant.dev/releases/20171206165245359550/lib/internal/Magento/Framework/View/Model/Layout/Merge.php on line 751
This can all be traced through the
_getPhysicalTheme
method. It's ridiculous that this even occurs. The physical presence of a theme should just break the site in a very expected way: that is, the frontend just doesn't appear. Don't try to be clever and modify the DB. Magento design decisions never cease to amaze me.You can imagine what this means for anyone migrating their databases to a new host. For example, you import your DB dump to a new host. Once the DB is migrated, you then issue the standard
magento setup:install
command. Guess what? Now your theme will never build. Why? Because the theme itself did not physically exist on the filesystem at the time of the install. What is supposed to come first, Magento--the chicken or the egg?
Can confirm that this was the issue for me to, mainly that the theme table in the database was in a state of limbo with my new theme. Had to reset it to type 0, and set the parent_id. The console error of: " ... In SourceThemeDeployCommand.php line 179" should be way more clearer!
This happened to me after I decided to format my computer. It worked only after:
rm -rf node_modules
rm -rf vendor
composer install
npm install
bin/magento setup:upgrade
grunt exec:<taskname>
Only now it works.
This happened to me after I decided to format my computer. It worked only after:
rm -rf node_modules
rm -rf vendor
composer install
npm install
bin/magento setup:upgrade
grunt exec:<taskname>
Only now it works.
I tried this and now it wont even recognize my grunt commands at all.
[~/public_html]# grunt clean
Loading "Gruntfile.js" tasks...ERROR
Error: Cannot find file. Alias "themes" not set. Use "filesRouter.set" method to set it.
at Object.get (/home/apollodesign/public_html/dev/tools/grunt/tools/files-router.js:69:19)
at Object.module.exports (/home/apollodesign/public_html/Gruntfile.js:20:30)
at loadTask (/home/apollodesign/public_html/node_modules/grunt/lib/grunt/task.js:315:10)
at Task.task.init (/home/apollodesign/public_html/node_modules/grunt/lib/grunt/task.js:434:5)
at Object.grunt.tasks (/home/apollodesign/public_html/node_modules/grunt/lib/grunt.js:111:8)
at Liftoff.(/usr/local/lib/node_modules/grunt-cli/bin/grunt:66:13)
at Liftoff.execute (/usr/local/lib/node_modules/grunt-cli/node_modules/liftoff/index.js:203:12)
at module.exports (/usr/local/lib/node_modules/grunt-cli/node_modules/flagged-respawn/index.js:51:3)
at Liftoff.(/usr/local/lib/node_modules/grunt-cli/node_modules/liftoff/index.js:195:5)
at Liftoff.(/usr/local/lib/node_modules/grunt-cli/node_modules/liftoff/index.js:170:7)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
Warning: Task "clean" not found. Use --force to continue.
Aborted due to warnings.
`
grunt-cli v1.3.2
grunt v1.0.4
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!
Confirmed in :
This issue is due to when you are setting the child theme you have previously set it incorrectly e.g incorrect casing of parent my issue was I had used a lower case M in the name of the parent theme so it did not link correctly to the parent theme 'Magento/blank' once I had done this and removed the theme and reinstalled it the grunt:exec command worked fine.
Issue
Parent Column: set to 0 due to incorrect name space on initial install
Another issue I found from that point is for some reason if you ran grunt:exec it would delete all static files and only return the compiled LESS files and the less files which were symlinked
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!
Running Magento 2.3.5-p1
This worked for me... Thanks!
This happened to me after I decided to format my computer. It worked only after:
rm -rf node_modules
rm -rf vendor
composer install
npm install
bin/magento setup:upgrade
grunt exec:<taskname>
Only now it works.
Number 5 worked for me ๐
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!
What a hero!
Most helpful comment
jesus โฆ lord โฆ
I found it โฆ
create a theme โฆ configure grunt's local-themes.js โฆย run exec -> error
open admin panel > content > themes (verify theme is listed)
run exec again: works
I THINK: It's caused by the missing entry in the theme table, which is created as soon as you load the theme list in the backend โฆ
can someone confirm that?!