magento2
magento2 copied to clipboard
Static deploy doesn't update files
Summary
There are files which gets never updated by command set:sta:dep - and it's very annoying if you need to this in production mode as it costs real- and downtime for clients. The only work around is to entire removing pub/static/frontend and/or var/view_preprocessed.
I don't know it this is reported yet, I really wonder if not. We are still expierencing this behaviour in 2.4.6
Examples
It affects multiple files if changes are made in theme files/overrides:
- If there is a compiled css file as in
/app/design/<theme>/../*.css - For template files for what content need to be preprocessed
- For translation files used for Javascript
Running set:sta:dep -f will update nothing here for pub/static/frontend and switching strategy has also no effect on this.
Additional Information
Your basic vanilla theme may does not trigger the bugs. Therefore it's needed to test it on a real world example. We work with different clients that uses different themes and expierence the same problems. One client even uses a custom theme that is only styles and templates, no custom code or interceptors that could cause troubles.
As written before - the most common one is if a CSS file from a theme is modified by the client. This can be a normal file included via Magento_Theme/layout/default_head_blocks.xml like this:
<css src="Magento_Theme::css/custom.css"/>
and placed in /app/design/frontend/theme/child/Magento_Theme/web/css/custom.css
We verified that the file was modified on the server.
We run the command set:sta:dep -f in production mode. It displays the process and everything seems fine.
However, if we inspect the file in pub/static/frontend/theme/child/en_US/Magento_Theme/css the file is there, minified as custom.min.css but contents are not updated and the file is not touched at all.
Only if we remove the complete folder or at least the affected area/theme, the changes will be applied.
Observation:
It works if the file is not there. But for some reasons the file will be ignored if it's already there.
Also applies to dynamic JS translation file, for example: en_US/js-translation.json.
We updated a theme translation file. It was ignored by deploy command. The changes will be applied if we remove en_US/js-translation.json manually and then run static deploy command again.
Proposed solution
No response
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [X] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [X] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @webloft. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance- upcoming 2.4.x release- For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this - To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @webloft,
Thanks for the report and collaboration!
We have tried to reproduce the issue in the vanilla 2.4-develop branch. But the issue is not reproducible for us. We have followed the below DevDocs:
https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/cli/static-view/static-view-file-deployment.html
Can you please let us know which kind of changes is not reflecting for you after running bin/magento setup:static-content:deploy command?
Thanks
Your basic vanilla theme may does not trigger the bugs. Therefore it's needed to test it on a real world example. We work with different clients that uses different themes and expierence the same problems. One client even uses a custom theme that is only styles and templates, no custom code or interceptors that could cause troubles.
As written before - the most common one is if a CSS file from a theme is modified by the client. This can be a normal file included via Magento_Theme/layout/default_head_blocks.xml like this:
<css src="Magento_Theme::css/custom.css"/>
and placed in /app/design/frontend/theme/child/Magento_Theme/web/css/custom.css
We verified that the file was modified on the server.
We run the command set:sta:dep -f in production mode. It displays the process and everything seems fine.
However, if we inspect the file in pub/static/frontend/theme/child/en_US/Magento_Theme/css the file is there, minified as custom.min.css but contents are not updated and the file is not touched at all.
Only if we remove the complete folder or at least the affected area/theme, the changes will be applied.
Observation:
It works if the file is not there. But for some reasons the file will be ignored if it's already there.
Also applies to dynamic JS translation file, for example: en_US/js-translation.json.
We updated a theme translation file. It was ignored by deploy command. The changes will be applied if we remove en_US/js-translation.json manually and then run static deploy command again.
Hello @webloft,
Thanks for the detailed description!
It helps us with the issue reproduction. The issue can be reproducible using a custom theme. After changing in the custom.css file we need to delete either the entire folder from the pub/static theme folder or the affected file only then the changes be reflected on the frontend.
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10573 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
Hi @webloft,
Adobe Commerce Engineering team started working on this issue. We will reach out to you if we need more information and you will get notified once the issue is fixed. Please leave comments for any further questions.
Thank you!
Hi @webloft,
Thank you for your valuable contribution. The Adobe Commerce Engineering team has reviewed the issue and confirmed that this is default behaviour of Magento.
For more details please find in below documentation about (Deploying static view files). https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/cli/static-view/static-view-file-deployment
Explanation: As outlined in the documentation, the correct procedure for deploying static view files in production mode includes the following steps: To deploy static view files: Log in to the Commerce server as, or switch to the file system owner. Delete the contents of <magento_root>/pub/static, except for the .htaccess file. Do not delete this file. Run the static view files deployment tool <magento_root>/bin/magento setup:static-content:deploy. Deleting the contents of pub/static and var/view_preprocessed is a required step to ensure that cached files do not persist after theme or content changes.
Summary: This is expected behavior in Magento. Manually clearing the static content directories is necessary and cannot be skipped.
If we have missed any details specific to your environment, please provide additional information, including screenshots or recorded short videos. This will help us to reproduce the issue locally and understand it better
Thanks.
@engcom-Bravo
this is the procedure we have to do on a production server if we want to ensure all files are updated correctly:
find pub/static/frontend -name '*.css' -delete
find pub/static/frontend -name '*.js' -delete
find pub/static/frontend -name '*.html' -delete
php bin/magento set:sta:dep -f
And if translations need to be updated:
find pub/static/frontend -name '*.json' -delete
We have verified this issue on different projects and versions.
- var/view_preprocessed is not the primary issue, maybe linked
- but the files are NOT updated in pub/static/frontend without those steps and that is an issue!
This is expected behavior in Magento. Manually clearing the static content directories is necessary and cannot be skipped.
And that's a joke I hope. How about to delete the files on deploying like we do on console? What's the benefit on the whole thing if we can't rely on any action and have to do all stuff manually?
Hi @webloft,
Thanks for your Update.
We have tested it on 2.4-develop with production mode and run the bin/magento setup:static-content:deploy command and found that files are updating in var/view_preprocessed directory but not updating in pub/static/frontend directory which is matches matches what is described in the official documentation.
The file only updates if it is first deleted from pub/static/frontend, and then run the static deploy command. However, files in the var/view_preprocessed directory do get updated correctly with that command.
Summary:
As per the documentation its a Magento default behaviour so this not a bug. But your point is also correct like after running the setup:static-content:deploy commend pub/static/frontend directory files should be updated. For this we will discuss with product owner and take the further action. After finalizing it, we will update you. Thank you for your input.