Allow setup:upgrade and setup:db-data:upgrade to run with a read-only app/etc (#26292) - #41153
Open
lbajsarowicz wants to merge 4 commits into
Open
Conversation
Contributor
Author
|
@magento run all tests |
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
5 tasks
Contributor
Author
|
@magento run all tests |
1 similar comment
Contributor
Author
|
@magento run all tests |
Installer::updateModulesSequence() unconditionally rewrote the "modules"
section of app/etc/config.php on every setup:upgrade run, even when the
resulting list was identical to what is already deployed. On read-only
deployments (immutable container images, chmod 444 app/etc/*) this made
setup:upgrade --keep-generated fail with:
The "config.php" deployment config file isn't writable.
Only write the file when the computed module list actually differs.
FilePermissions::getMissingWritableDirectoriesForDbUpgrade() listed app/etc
as a directory that must be writable, so setup:db-data:upgrade (and the data
phase of setup:upgrade) refused to start on read-only deployments with:
Missing write permissions to the following paths:
<root>/app/etc
Data and schema upgrade write to the database and var/ only. Keep the var/
check and drop app/etc from the precondition. A patch that genuinely needs
to write deployment configuration still gets a precise error from
DeploymentConfig\Writer at the moment of the write.
Add @see reference to the deprecated getMissingWritableDirectoriesForInstallation() and fix indentation of use/attribute lines inside the braced namespace of InstallerTest.
Contributor
Author
|
@magento run all tests |
lbajsarowicz
force-pushed
the
fix/26292-read-only-app-etc-upgrade
branch
from
August 27, 2026 21:06
53545f2 to
1107ba6
Compare
…ad-only-app-etc-upgrade
Contributor
Author
|
@magento run Unit Tests, WebAPI Tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (*)
setup:upgrade --keep-generatedandsetup:db-data:upgradecannot run whenapp/etcis read-only, which is the expected state for immutable deployments (prebuilt container images, Kubernetes,chmod 444 app/etc/*). Two independent causes, one commit each:Installer::updateModulesSequence()always rewritesapp/etc/config.php.createModulesConfig()recomputes themodulesarray and callsWriter::saveConfig()unconditionally, even when the result is byte-for-byte what is already deployed. On a read-onlyconfig.phpthis fails withThe "config.php" deployment config file isn't writable.Fix: only call
saveConfig()when the computed module list differs (!==, so a changed module sequence still triggers a write) from the currentmodulessection.FilePermissions::getMissingWritableDirectoriesForDbUpgrade()requiresapp/etcto be writable.Installer::installDataFixtures()runs this precondition, sosetup:db-data:upgrade(and the data phase ofsetup:upgrade) aborts withMissing write permissions to the following paths: <root>/app/etcbefore touching the database. The DB upgrade itself writes only to the database andvar/.Fix: drop
DirectoryList::CONFIGfrom the list;var/is still required. A patch that genuinely needs to write deployment configuration (e.g.Magento\Backend\Setup\Patch\Data\MigrateRedisBackendConfig) still gets a precise error fromDeploymentConfig\Writerat the moment of the write instead of a blanket refusal up front.No public signatures changed.
Related Pull Requests
cache_types/env.phpside of Read-only app/etc/ #26292 and is on hold; this PR is independent of it.Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento setup:upgradeonce soconfig.phpis in sync.chmod 555 app/etc && chmod 444 app/etc/*bin/magento setup:upgrade --keep-generatedUpgrade failed: The "config.php" deployment config file isn't writable.Upgrade completed successfully.bin/magento setup:db-data:upgradeMissing write permissions to the following paths: /var/www/html/app/etcbin/magento module:disable Magento_Wishlist), runbin/magento setup:upgrade --keep-generated—config.phpis rewritten as before.Questions or comments
Unit tests:
setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php(write skipped when unchanged, write performed when module order changes) andlib/internal/Magento/Framework/Setup/Test/Unit/FilePermissionsTest.php(read-onlyapp/etcnot reported). Both new tests fail against2.4-developwithout the fix.Contribution checklist (*)