Magento2: php bin/magento setup:static-content:deploy displays errors in console

Created on 29 Dec 2016  路  23Comments  路  Source: magento/magento2

Preconditions

  1. PHP 5.6.29 (cli) (built: Dec 9 2016 07:40:09)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v6.0.7, Copyright (c) 2002-2016, by ionCube Ltd.
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
  2. mysql Ver 14.14 Distrib 5.6.35, for Linux (x86_64) using EditLine wrapper
  3. Magento 2.1.3 Developer Mode

    Steps to reproduce

Setup Magento 2 Brand new through uploading files and running setup wizard and installtion success with no errrors.

Install new theme, run upgrade command and deploy static content succesfully with no errors.

After a day or 2, make changes and run deploy static command issues arises

Expected result

Run static deploy command with no issues or errors in console

Actual result

Givers many errrors for luma and blank theme, my custom theme

  1. Log
[2016-12-29 19:34:50] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_6d41d8cd98f00b204e9800998ecf8427e and handles : Please correct the XML data and try again.  [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/email-inline.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email-inline.less
Compilation from source: 
frontend/Magento/blank/en_US/css/email-inline.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/email-inline.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email-inline.less
Compilation from source: 
frontend/Magento/luma/en_US/css/email-inline.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/email-fonts.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email-fonts.less
Compilation from source: 
frontend/Magento/blank/en_US/css/email-fonts.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/email-fonts.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email-fonts.less
Compilation from source: 
frontend/Magento/luma/en_US/css/email-fonts.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/print.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/print.less
Compilation from source: 
frontend/Magento/blank/en_US/css/print.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/print.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/print.less
Compilation from source: 
frontend/Magento/luma/en_US/css/print.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/email.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email.less
Compilation from source: 
frontend/Magento/blank/en_US/css/email.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/email.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/email.less
Compilation from source: 
frontend/Magento/luma/en_US/css/email.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/blank [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/luma [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/blank [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/styles-m.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/styles-m.less
Compilation from source: 
frontend/Magento/blank/en_US/css/styles-m.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/blank [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/luma [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/styles-m.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/styles-m.less
Compilation from source: 
frontend/Magento/luma/en_US/css/styles-m.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/blank [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/blank/en_US/css/styles-l.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/styles-l.less
Compilation from source: 
frontend/Magento/blank/en_US/css/styles-l.less
Unable to get content for 'frontend/Magento/blank/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/luma [] []
[2016-12-29 19:35:46] main.NOTICE: magento_import returns empty result by path css/source/_extend.less for theme Magento/luma [] []
[2016-12-29 19:35:46] main.CRITICAL: 
Compilation from source: 
frontend/Magento/luma/en_US/css/styles-l.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []
[2016-12-29 19:35:46] main.CRITICAL: Compilation from source: /var/www/my-website.com/public_html/vendor/magento/theme-frontend-blank/web/css/styles-l.less
Compilation from source: 
frontend/Magento/luma/en_US/css/styles-l.less
Unable to get content for 'frontend/Magento/luma/en_US/css/source/lib/_lib.less' [] []

I have a serious issue which is ongoing with running php bin/magento setup:static-content:deploy.

First I have installed magento 2.1.3 by uploading the files and run the setup wizard, all went fine, installed my theme and created a custom theme and all went fine whilst using the command etc.

But at some point, for whatever reason, the command ends up throwing many errors. The frontend has also lost functionality and no css and js is loading too.

The errors are above in the console and sytem.log, too many related to all themes active such as blank and luma.

I have checked a few resources and followed the instructions but no luck, some followed are:

1) https://github.com/magento/magento2/issues/2273

2) http://magento.stackexchange.com/questions/108919/static-content-deploy-issue

3) http://stackoverflow.com/questions/37964713/not-able-to-deploy-static-content-magento2-0

4) How to fix the problem of loading css and javascript files?
Login to ssh, go to magento directory for instance i'm
cd /var/www/html/magento
1: rm -rf var/di/* var/generation/* var/cache/* var/page_cache/* var/view_preprocessed/* var/composer_home/cache/*
2: sudo chmod 777 var -R
3: sudo chmod 777 pub -R
4: sudo php bin/magento setup:static-content:deploy
5: Repeat step 2 & 3.

And some others I found on google but no resolution to the issue.

Please, please help me as it is urgent I resolve this.

Thank you in advance.

Frontend Fixed in 2.2.x Fixed in 2.3.x Format is valid needs update bug report

Most helpful comment

@andidhouse @maxbucknell Just informing you that I gave up on it and reinstalled Magento 2.1.3 for the 14th time as each time, different issues occur :( I have spent Around $6000 on extensions, customization etc. and it is a shame that it is this difficult to have a store running on Magento 2 without issues.

I honestly wish I listened to the few that advised not to migrate to Magento 2 last year some time and stick to Magento 1 for a long while but I didn't listen and now paying for it. It has become very stresful now and time consuming as well as costly. Mainly concentrating on hiring developers in resolving bugs instead of actually working on the platform and making it what I would like my store to become. It's bleeding me out.

So unfortunate but as much as I love Magento and what it offers, with much regret, I wish that I had invested in another platform now.

I truly hope that Magento 2, resolves many bugs in it's next release which with the same hope is rather soon. Fingers crossed.

Please Magento 2, sort the majority of bugs out soon as resonably possible.

Thanking you in advance.

All 23 comments

i reported this also here:

https://github.com/magento/magento2/issues/7813

this is a blocker for going live once again. Magento2 Team can you pls describe how a shop should go online with this bug?

Also this is a new bug introduced in 2.1.3 - i really loose trust in the new m2 releases at all as more and more bugs are introduced with each release...

It seems like it's failing to find the file css/source/lib/_lib.less in your compilation path. Please verify that the file lib/web/css/source/lib/_lib.less exists in your installation, and please let me know the output of the command find var/view_preprocessed -name _lib.less.

Hi,

output is:

root@euve103495:/var/www/html/magento2# find var/view_preprocessed -name _lib.less
var/view_preprocessed/css/adminhtml/Magento/backend/en_US/css/source/lib/_lib.less
var/view_preprocessed/css/adminhtml/Magento/backend/de_DE/css/source/lib/_lib.less
var/view_preprocessed/css/frontend/Company/theme/de_DE/css/source/lib/_lib.less

lib/web/css/source/lib/_lib.less

screen

Thanks!

@maxbucknell the files are there right?

@andidhouse And your output is identical to that of @GlobalOutsourcing ? Or are you receiving different output when you run it, as per #7813?

@andidhouse @maxbucknell Just informing you that I gave up on it and reinstalled Magento 2.1.3 for the 14th time as each time, different issues occur :( I have spent Around $6000 on extensions, customization etc. and it is a shame that it is this difficult to have a store running on Magento 2 without issues.

I honestly wish I listened to the few that advised not to migrate to Magento 2 last year some time and stick to Magento 1 for a long while but I didn't listen and now paying for it. It has become very stresful now and time consuming as well as costly. Mainly concentrating on hiring developers in resolving bugs instead of actually working on the platform and making it what I would like my store to become. It's bleeding me out.

So unfortunate but as much as I love Magento and what it offers, with much regret, I wish that I had invested in another platform now.

I truly hope that Magento 2, resolves many bugs in it's next release which with the same hope is rather soon. Fingers crossed.

Please Magento 2, sort the majority of bugs out soon as resonably possible.

Thanking you in advance.

Unfortunately, I could not reproduce the issue as you described it on 2.1.3 version.

Preconditions:

  1. Server DocumentRoot is configured on pub directory
  2. Permissions is configured
  3. Magento 2.1.3 is installed
  4. Stores > Configuration > Advanced > Developer > CSS Settings settings:
    Merge CSS Files => No
    Minify CSS Files => No

Steps to reproduce:

  1. Make sure that you set your Magento application to the developer or default mode.
  2. Create Test theme

    1. Create a directory for the theme under app/design/frontend/TestNamespace/theme_dir
    2. Add app/design/frontend/TestNamespace/theme_dir/registration.php
      ```php
      use Magento\Framework\Component\ComponentRegistrar;

    ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/TestNamespace/theme_dir', __DIR__);
    ```

    1. Add app/design/frontend/TestNamespace/theme_dir/theme.xml
    <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
        <title>Test Theme</title>
        <parent>Magento/luma</parent>
        <media>
            <preview_image>media/preview.jpg</preview_image>
        </media>
    </theme>
    
    1. Add app/design/frontend/TestNamespace/theme_dir/media/preview.jpg (can be copied from luma theme)
    2. Test custom CSS file:

      1. Add app/design/frontend/TestNamespace/theme_dir/Magento_Theme/layout/default_head_blocks.xml

        xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="css/source/custom-css-file.css"/> </head> </page>

      2. Add CSS file with some test styles app/design/frontend/TestNamespace/theme_dir/web/css/source/custom-css-file.css

        css /** custom css file test */ footer * { color: red !important; }

    3. Test custom LESS file:

      1. Change app/design/frontend/TestNamespace/theme_dir/Magento_Theme/layout/default_head_blocks.xml

        xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="css/source/custom-css-file.css"/> <css src="css/source/custom-less-file.css"/> </head> </page>

      2. Add LESS file with some test styles app/design/frontend/TestNamespace/theme_dir/web/css/source/custom-less-file.less

        css /** custom less file test */ @fontColor: red; .page-header .panel.wrapper, .page-header .panel.wrapper * { color: @fontColor !important; }

        If the system does not find the included CSS files, it searches for the same file names with a .less extension.

    4. Override parent styles test:

      1. Add app/design/frontend/TestNamespace/theme_dir/web/css/source/_theme.less

        css /** override parent styles test */ @color-gray-middle3: yellow;

    5. Extend parent styles test:

      1. Add app/design/frontend/TestNamespace/theme_dir/web/css/source/_extend.less

        css /** extend parent styles test */ @import '_test-import.less';

      2. Add LESS file with some test styles app/design/frontend/TestNamespace/theme_dir/web/css/source/_test-import.less

        css /** import styles test */ @headerFontSize: 72px; @headerFontColor: navy; h1 { font-size: @headerFontSize !important; color: @headerFontColor !important; }

  3. Apply a theme on backend
  4. Clear the cache
  5. Enable production mode
  6. Open frontend
    2017-02-06_1331
  7. Run bin/magento setup:static-content:deploy
    No errors during style compilation

If your style changes do not apply after refreshing the page, cleaning the static files cache might help. See the Clean static files cache topic for instructions how to do this.

Related reading

Create a storefront theme
Simple ways to customize a theme's styles
Cascading style sheets (CSS)
Include CSS
Apply and configure a storefront theme

Aditional questions:

  • How is configured your DocumentRoot?
  • Provide permissions info for pub/static, var directories
  • Provide Stores > Configuration > Advanced > Developer > CSS Settings settings
  • Provide CONTENT > Design > Configuration data
  • Provide your theme custom less files (and structure)

Please add more details to your description of the steps you followed when identifying this issue. Screenshots or logs would be helpful, too.
Thanks in advance

this is why i recommended magento to set up some test systems with different configurations for users to test. In our case some bugs are related to the updates from 2.1.2 etc. - no chance here to say what goes when wrong if you must take into account that the updates cause bugs as well.

@naydav there are a lot of deploy and compile errors out here especially when updating the magento system... is there a way to fix this - i mean like this nobody can make an update on a productive system at all.

Hi @GlobalOutsourcing

Can you tell if you are using Redis for caching?

Thanks

I get the same error as GlobalOutsourcing.

I am not using Redis.

It was working when I was on 2.1.3 to 2.1.4. Never had any issue until some time recently it started to break when I was installing a plugin.

I have also tried updating it to 2.1.5 but the issue remains.

it seems that the 2.1.5 package or repo or whatever you call it, has missing css files.

I was able to partially solve the problem by replacing some of the css files, as many as i could practically find, back into the vendor folder.

@naydav That that help to shed some light on the situation?

I posted a related issue when I deploy my static files in production mode (there's another issue switching without --skip-compilation). Then frontend runs but styles, functionality and elements are wrong, same as you @GlobalOutsourcing. Did you solved? I had 2 days searching for some fix and I found many questions in this way but no solutions available. Magento version is 2.1.3

I really appreciate your answers.

Any solution to this?

Not shure if it helps you but we solved our deploy errors with this:

sudo php bin/magento setup:static-content:deploy --jobs=0 && sudo php bin/magento setup:static-content:deploy de_DE --jobs=0


"jobs=0" did the trick for us

@andidhouse "jobs=0" did not work for me :(

For me the error was:-
ParseError: Unexpected input in _theme.less on line 386, column 1

I copied this file from Blank theme, placed in my theme. And then commented out this line, and s:s:d errors solved. This can be helpful

Figuring out further the exact reason

this is not fixed! this is version 2.2.1
screen shot 2017-12-07 at 01 44 18

can someone contact me? I think instead I might be able to give access for the magento team to troubleshoot on actual dysfunctional installation than to attempt to replicate to no avail.

turns out if there is something missing in the lib folder, this will never recover. In order to do so, download a fresh copy of magento and replace the lib folder.

calvintwr thank you for pointing me in the right direction

no problem at all. i think people using magento should try to help each other out and reduce the pain.

Was this page helpful?
0 / 5 - 0 ratings