7

When I run php bin/magento setup:static-content:deploy I have had some errors in my theme. I have got to the bottom of them but it was a pain, I had to manually go through all my LESS files to check for errors.

The culprit was an import that was missing an underscore.

I checked var/log/debug.log and var/log/support_report.log but these don't seem to log LESS errors. Client side compilation doesn't either, this just returned a 404 for styles-l.css and styles-m.css as the deployment must have failed before it reached these files.

TL:DR

Now my question is, are the static content deploy errors logged anywhere? It would have been so much easier if there was a log along the lines of x.less can not be imported.

This is Magento 2.0.4 with a custom theme using Luma as a parent.

Example of my error:

=== frontend -> ThemeName/default -> en_GB ===
...
Successful: 2248 files; errors: 1
---
8

I reckon there's several types of errors that can be triggered by the deployment.

First you can see that Exception are handled directly in the execution in Magento/Deploy/Console/Command/DeployStaticContentCommand.php:

    catch (\Exception $e) {
        $output->writeln('<error>' . $e->getMessage() . '</error>>');
        if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $output->writeln($e->getTraceAsString());
        }
        return;
    }

Regarding the errors that are counted it's a totally different system, you need to look into the Magento/Deploy/Model/Deployer class, the output you got is written by the deploy() method:

$this->output->writeln("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n");

Now if we check when this errorCount variable is incremented, we find the following in the deployFile() method:

    catch (\Exception $exception) {
        $this->output->write('.');
        $this->verboseLog($exception->getTraceAsString());
        $this->errorCount++;
    }

And as you may have already guessed, the verboseLog() method only outputs when the command is run on verbose mode:

private function verboseLog($message)
{
    if ($this->output->isVerbose()) {
        $this->output->writeln($message);
    }
}

So I reckon you need to run your command like this to see the errors:

php bin/magento setup:static-content:deploy -v

If it doesn't work try the extra verboses:

php bin/magento setup:static-content:deploy -vv
php bin/magento setup:static-content:deploy -vvv
  • Thank you. It's a shame the error messages don't help me as a front-end developer, it seems to be a LESS error as CSS and preprocessing is mentioned a few times. I was hoping for an error that mentioned where the error occurred. This does the answer question though so I will mark as correct. – Ben Crook Apr 28 '16 at 12:11
  • @Ben-Space48 feel free to create an issue on github to ask for such feature ;) – Raphael at Digital Pianism Apr 28 '16 at 12:13
  • So has anybody determined exactly how many -v are required? – peedee Sep 14 '16 at 8:20
  • @peedee you have up to 3. The more v the more verbosity ;) – Raphael at Digital Pianism Sep 14 '16 at 8:23
  • 2
    yes I noticed. here is what happens: one -v is enough to give you the stacktrace of the error amidst all of the printed dots. if you use 2 or 3 v's then it doesn't print dots anymore but instead the name of every single processed file, which makes it difficult to find the stacktrace. therefore I recommend only one v. the verbosity of the stacktrace itself doesn't increase with more v. – peedee Sep 14 '16 at 8:27
3

You can often see errors within your less by viewing the css file that is generated on your development environment. This doesn't quite answer the question but will hopefully be helpful to someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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