Strange Error when running setup:upgrade after module installation
-
09-10-2020 - |
Question
I have tried to install wyomind google shopping and have the following error when running bin/magento setup:upgrade.
[UnexpectedValueException]
Unable to retrieve deployment version of static files from the file system.
[Magento\Framework\Exception\FileSystemException]
Cannot read contents from file "/var/www/vanillamage2/public_html/pub/stati
c/deployed_version.txt" Warning!file_get_contents(/var/www/vanillamage2/pub
lic_html/pub/static/deployed_version.txt): failed to open stream: No such f
ile or directory
I have tried this on 2 seperate server and 3 seperate installation of Magento 2.1.7 however recieve the same issue each time. I have seen similar issues here:
https://github.com/magento/magento2/issues/6426
and
http://olivernam.com/magento2-frontpage-error-after-deploying-static-files
So have tried many solutions mentioned here including redeploying static files , resetting permissions, removing static content, placing empty deployment_version.txt ect but without any luck. I have even set that file to 777 and has correct owner and am pretty sure that is not the issue as my solutions below wouldn't change the permissions of this file.
There are only 2 ways I can get the setup:upgrade to run.
- Disabling the plugin.
- Rename app/code/Wyomind/SimpleGoogleShopping/Setup/UpgradeData.php to UpgradeData.bak
Doing either of these allow 'setup:upgrade' to run however Wyomind are suggesting this is a problem on my side and not their plugin and so are unwilling to help.
Is there anything anyone can suggest that may be causing this issue?
Solution
Need to update in Database core_config_data table,
If record (path field value = 'dev/static/sign'
) exist in core_config_data
table
UPDATE core_config_data SET value = 0 WHERE path = 'dev/static/sign'
If record not exist then run below query to Insert record,
INSERT INTO core_config_data VALUES (null, 'default' , 0, 'dev/static/sign', 0);
After that run your command
OTHER TIPS
In my case, I ran php bin/magento setup:static-content:deploy
and the error disappeared.
It seems to have nothing to do with the google module. It can happen after any deployment; especially if you are dealing with Magento in production
mode.
Running bin/magento setup:upgrade
removes content of the generated
directory. This is fine in development
mode, because the contents of the generated
directory are generated dynamically. But in production
mode, the generated
directory is neither generated dynamically, nor automatically. This means, it is necessary to trigger the generation of the content of the generated
directory manually:
bin/magento setup:static-content:deploy en_GB en_US en_AU
(Hint: All locales of your installation need to be added)
This is the default way how to solve it. But in some cases, you might want to keep the content of your generated
directory. Maybe, because its contents did not change during the deployment. Maybe, because you have generated its contents in another environment or by a deployment pipeline, and want to just deploy it to the current server via copying the directory.
You still might need to run bin/magento setup:upgrade
in such a case, but you would not want it to remove anything from the generated
directory. For this purpose, the smart Magento developers have added the keep-generated
flag:
bin/magento setup:upgrade --keep-generated
The solution from github is working for me. https://github.com/magento/magento2/issues/6426#issuecomment-243879287
you could just create empty file in following path: pub/static/deployed_version.txt
then run static content deploy
php bin/magento setup:static-content:deploy
On Magento Cloud run by ssh:
vendor/magento/ece-tools/bin/ece-tools deploy
This worked for me:
php bin/magento setup:static-content:deploy -ea_php 72
( -ea_php 72 is used to force th use of PHP version 7.2, because my server inherit is 7.0.32 )
You need update on core_config_data table,
You can search with "path" is "dev/static/sign"
Change value from 1
to 0
;
Or you can update with query:
UPDATE core_config_data SET value = 0 WHERE path = 'dev/static/sign'