Open piotrkwiecinski opened 2 weeks ago
Hey @piotrkwiecinski, yeah I know, we probably should do better error handling in this module, if you look at the first line of generated css, you'll see some errors. Good that you've opened a ticket, this has been on my mind for a long time but I keep forgetting about it.
Most likely, you're running into a less/css bug in the magento pagebuilder module, here's a fix to fix those: https://github.com/magento/magento2-page-builder/pull/777 (fix was created 3 years ago, but only got merged 3 weeks ago, so I guess it will be included in Magento 2.4.8)
@hostep thank you for a quick reply. I'll try to apply the patch.
Yeah another lightning fast PR processing in Magento core🙂
Some observations after looking a bit more closer into this:
2>&1
at the end of any command we try to execute: https://github.com/magento/magento2/blob/8f07562631b5982098176ae87f74f986adf2bf74/lib/internal/Magento/Framework/Shell/CommandRenderer.php#L19, this is the reason why stderr and stdout are mashed together in the output and breaks the first line of css if errors are present--silent
flag to the lessc
commandI'm thinking of changing the default less compilation flag from --no-color
to --no-color --silent
, so no errors are outputted in the generated css.
Only downside I'm seeing is that there is no indication anywhere that you have an error in your less code. But I guess that's fine, since the compiler Magento uses also doesn't pick this up...
Does this sound like an okay solution to you @piotrkwiecinski?
@hostep it may be a good solution for now. Ideally we would forward these errors to stderr so they're outputted in the console.
In one project in testing this module some css files aren't generated at all in the CI pipeline.
I'm trying to figure out what's the difference between my local dev vs pipeline itself.
I'll try to poke around the code in upcoming weeks.
Okay, as for separating stdout
and stderr
, I'll try to take a look at the possibilities of switching to proc_open
or using the symfony/process
library, both should allow us to get the separate output and then doing 'something' (outputting or logging, or both) with them.
I have some success with Symfony\Process:
Compilation from source: /var/www/html/app/design/frontend/Pearl/weltpixel/web/css/styles-l-temp.less
The command "'/usr/bin/node' '--no-deprecation' '/var/www/html/node_modules/.bin/lessc' '--no-color' '/var/www/html/var/view_preprocessed/pub/static/frontend/Pearl/weltpixel_custom/en_GB/css/styles-l-temp.less'" failed.
Exit Code: 1(General error)
Working directory: /var/www/html
Output:
================
Error Output:
================
ParseError: Unrecognised input. Possibly missing opening '{' in /var/www/html/var/view_preprocessed/pub/static/frontend/Pearl/weltpixel_custom/en_GB/css/source/_icons.less on line 11, column 1:
10
11 }
12
I just made quick swap for the shell runner. https://github.com/piotrkwiecinski/magento2-module-less-js-compiler/commit/1dc75740d81734444db8a5ac35339f49d73c3543 .
I'll try to do some additional tests next with with the other project and see if it helps me with debugging missing css files.
@hostep have you encountered the problem with missing icons in admin dashboard while using this plugin?
I don't see any errors in system.log.
Magento version: 2.4.6-p5 Less: 3.13.1
I tested it in 2 different projects. Looks like @font-face: 'Admin Icons' isn't added.