Magento 2.2.8 | setup:static-content:deploy gives errors | Cannot read contents from file jquery.fileupload-ui.css No such file or directory
-
01-03-2021 - |
Question
I can't deploy static content on my production site. Running command:
php bin/magento setup:static-content:deploy en_GB
Gives me following error:
[Magento\Framework\Exception\FileSystemException] Cannot read contents from file "magento2/http/pub/static/adminhtml/Magento/backend/en_US/Magento_ConfigurableProduct/product/product.css" Warning!file_get_contents(magento2/http/pub/static/adminhtml/Magento/backend/en_US/Magento_ConfigurableProduct/product/product.css): failed to open stream: No such file or directory
For some reason, when not specifying the locale, it went through fine.
What could be causing the problem?
UPDATE:
The file permission of the aforementioned file looks a bit weird?
lrwxrwxrwx 1 xxx xxx 113 May 8 15:08 product.css -> magento2/http/vendor/magento/module-configurable-product/view/adminhtml/web/product/product.css
UPDATE 2:
Found out that this is a symlink that points to a file somewhere else on my server. These are the file permissions of the file where the symlink is pointing to:
-rw-r--r-- 1 xxx xxx 3863 May 7 06:35 product.css
Should I change these file permissions? If so, what would I changed them to to keep me site secure?
Solution 3
Found a solution by disabling the Symlinks.
Navigate to Stores -> Configuration -> Advanced -> Developer -> Template Settings and set “Allow Symlinks” to “No”.
Change Materialization Strategy in magento_root/app/etc/di.xml
. Change this:
<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
<arguments>
<argument name="strategiesList" xsi:type="array">
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
<item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
</argument>
</arguments>
</virtualType>
To:
<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
<arguments>
<argument name="strategiesList" xsi:type="array">
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
<item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
</argument>
</arguments>
</virtualType>
Then remove the static files, flush cache and deploy static content:
From magento_root (Be careful not to remove the .htaccess
files):
rm -rf pub/static/adminhtml pub/static/frontend && php bin/magento cache:clean && php bin/magento cache:flush
php bin/magento setup:static-content:deploy
OTHER TIPS
That caused by permission.
- You can upgrade and deploy again.
php bin/magento setup:upgrade php bin/magento setup:static-content:deploy en_GB
- if it still error, pls run command on root:
find app/code lib var generated vendor pub/static pub/media app/etc ( -type d -or -type f ) -exec chmod g+w {} + && chmod o+rwx app/etc/env.php
After that, repeat step 1.
It seems like permission issue for pub/static
So just give necessary permission for pub/static then run your command and of course static content deploy will create a down time as well.
As of now run the below command in your root
chmod -R 755 pub/static/
or
chmod -R 777 pub/static/
EDIT :
Run the below command then deploy
rm -rf pub/static/adminhtml
Hope this helps.