Why is my Magento 2.4.6-p3 exceptions.log file showing 'LESS file is empty' error?

If you have recently upgraded your Magento installation from version 2.4.0 to 2.4.6-p3, you may encounter an error in your exceptions.log file.

The error message reads as follows:


main.CRITICAL: Magento\Framework\View\Asset\ContentProcessorException: Compilation from source: LESS file is empty: frontend/new/latest/en_US/Magento_Swatches/css/swatches.less in /chroot/home/a/com/html/vendor/magento/framework/Css/PreProcessor/Adapter/Less/Processor.php:99

This error is related to the LESS file being empty and can cause issues with the compilation process and render your storefront improperly.

Let's delve into the steps to debug and resolve this issue.

Check File Permissions

Firstly, it's essential to ensure that the file permissions are correctly set for the affected LESS file and its directory.

Navigate to the frontend/new/latest/en_US/Magento_Swatches/css/ directory and verify the file permissions using the following command:


ls -l swatches.less

If the permissions are incorrect, you can modify them using the chmod command.

Verify LESS File Content

Next, examine the content of the swatches.less file to determine if it is indeed empty.

You can use the cat command to display the file contents:


cat swatches.less

If the file appears to be empty or contains unexpected characters, you may need to restore it from a backup or recompile the LESS file from its source.

Review Compilation Process

It's crucial to review the compilation process to identify any potential issues.

Navigate to the directory containing the compilation files and examine the relevant logs and configuration settings.

Check Module Compatibility

Since the error is related to Magento_Swatches, it's important to verify the compatibility of this module with the upgraded Magento version.

Ensure that the module and its dependencies are compatible with Magento 2.4.6-p3.

You can also check for any available updates or patches for the Magento_Swatches module.

Rebuild Static Files

As a potential solution, you can try rebuilding the static files using the following commands:


php bin/magento setup:upgrade

## php bin/magento setup

static-content:deploy -f

php bin/magento cache:clean

Following these steps should help in resolving the 'LESS file is empty' compilation error after upgrading Magento to version 2.4.6-p3.

Remember to back up your files and database before making any significant changes to your Magento installation.