[5.x]: Not Supported: Changes to the project config are not possible while in read-only mode.
What happened?
Description
php craft update all
i've set my allowAdminChanges to true, run composer update and do php craft up on my local. But still get this error.
im trying to update craft from 5.5.9 to 5.6.11
Not Supported: Changes to the project config are not possible while in read-only mode.
Migration: craft\migrations\m241125_122914_add_viewUsers_permission
Output:
Exception: Changes to the project config are not possible while in read-only mode. (/var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php:554)
#0 /var/www/html/vendor/craftcms/cms/src/services/ProjectConfig.php(526): craft\services\ProjectConfig->_setInternal()
#1 /var/www/html/vendor/craftcms/cms/src/migrations/m241125_122914_add_viewUsers_permission.php(49): craft\services\ProjectConfig->set()
#2 /var/www/html/vendor/craftcms/cms/src/db/Migration.php(50): craft\migrations\m241125_122914_add_viewUsers_permission->safeUp()
#3 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(233): craft\db\Migration->up()
#4 /var/www/html/vendor/craftcms/cms/src/db/MigrationManager.php(149): craft\db\MigrationManager->migrateUp()
#5 /var/www/html/vendor/craftcms/cms/src/services/Updates.php(245): craft\db\MigrationManager->up()
#6 /var/www/html/vendor/craftcms/cms/src/controllers/BaseUpdaterController.php(499): craft\services\Updates->runMigrations()
#7 /var/www/html/vendor/craftcms/cms/src/controllers/UpdaterController.php(213): craft\controllers\BaseUpdaterController->runMigrations()
#8 [internal function]: craft\controllers\UpdaterController->actionMigrate()
#9 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#10 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#11 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#12 /var/www/html/vendor/craftcms/cms/src/web/Application.php(361): yii\base\Module->runAction()
#13 /var/www/html/vendor/craftcms/cms/src/web/Application.php(753): craft\web\Application->runAction()
#14 /var/www/html/vendor/craftcms/cms/src/web/Application.php(254): craft\web\Application->_processUpdateLogic()
#15 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#16 /var/www/html/web/index.php(12): yii\base\Application->run()
#17 {main}
Steps to reproduce
- php craft update all
- composer update
- php craft up
Expected behavior
Actual behavior
Craft CMS version
5.6.11
PHP version
8.2
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
Check your .env file. Do you define a CRAFT_ALLOW_ADMIN_CHANGES variable in there?
i actually already set it on general.php settings
$config = GeneralConfig::create()
->timezone('Asia/Singapore')
->defaultWeekStartDay(1)
->omitScriptNameInUrls()
->preloadSingles()
->preventUserEnumeration()
->cpTrigger(null)
->headlessMode()
->disallowRobots()
->baseCpUrl(App::env('BASE_CP_URL'))
->aliases([
'@webroot' => dirname(__DIR__) . '/web',
'@primaryUrl' => App::env('PRIMARY_SITE_URL'),
'@previewBaseUrl' => '@primaryUrl/api/preview',
])
->devMode(true)
->allowAdminChanges(true)
;
Right, but if you have a CRAFT_ALLOW_ADMIN_CHANGES environment variable set, that will take precedence. Did you check?
Thanks @brandonkelly , when i use ->allowAdminChanges(true) i don't set the CRAFT_ALLOW_ADMIN_CHANGES on my env, but when i put the CRAFT_ALLOW_ADMIN_CHANGES , now its work.
Try commenting out your change, and then going to Utilities → PHP Info within your control panel, and searching for CRAFT_ALLOW_ADMIN_CHANGES. Are you seeing any references to it there?
If so, then CRAFT_ALLOW_ADMIN_CHANGES is in fact getting set somewhere – just maybe not in your .env file.
I have a similar issue, but not sure if it's really related.
I've set the CRAFT_ALLOW_ADMIN_CHANGES=false to disable changes via the frontend.
When I run php craft update all --force --backup 1 --interactive 0 --minor-only it first tries to run the migrations and then aborts with the error Changes to the project config are not possible while in read-only mode. and reverts everything.
If I understand it correctly, --force should exactly prevent this. Is this behavior expected and/or is there a solution to it since my update process is automated and I don't want to edit the .env file manually?
Update: I experience the issue since Craft CMS 5.6.17 and also 4.14.15. I think before it worked without any issues.
@ammannbe --force just gets you passed the allowUpdates config setting, if that’s disabled.
allowAdminChanges is a different beast. The update command has never made an exception for that.