1

Probably my fault — I’m generally OK with this stuff until something goes wrong — but…

I updated a local install (MAMP PRO) to Craft 3.7 by clicking that lovely 'update' button. And it worked fine, first time, no issues.

I then went to update a staging install on my server via SSH and it ran through until it hit this error:

*** applying m210602_111300_project_config_names_in_config
Exception: Changes to the project config are not possible while in read-only mode. (/home/***/***.***.***/vendor/craftcms/cms/src/services/ProjectConfig.php:492)

😬

So then I decided to back out, and told it to restore the database backup as prompted. Which lead to this error:

error: PDOStatement::execute(): MySQL server has gone away
The SQL being executed was: SELECT GET_LOCK('c4ba60e2215081fdd4fd2710bb13db075668ce52', 2)

😬😬

At this point my staging site is giving me the Craft branded 'site unavailable' message you get if a version is out of sync somewhere.

But it said I could manually restore using [file]. I FTP to the staging space, and the file (plus a couple of others) are there. So I download them.

I open up TablePlus, connect to the database, and use the restore DB option with the file the terminal specified. It says it’s done it, and it looks OK to the untrained eye (ie. I can see content in there) but now my staging site has changed to an internal server error.

😬😬😬

So… I think my best bet is to trash the current staging install, build a new one from the local database, and manually copy and paste the data (that a client had tweaked) from the content table into the brand new site. Irritating, and a bit slow, but hopefully OK.

But I’m concerned about that initial error (the read-only mode). Did I have something misconfigured to set this off?

The original install on the staging site was created with composer, and I understood that composer sets the right permissions as it performs the install.

I’m sure I have updated this install, via SSH, at least once, because it’s a few months old and I try to keep up to date.

Any tips, suggestions, observations etc. before I dig myself a deeper hole gratefully received.

1 Answer 1

2

Changes to the project config are not possible while in read-only mode.

This is the error you get when your allowAdminChanges config setting is set to false, which is the default for staging/production environments. If you have not modified the default config/general.php, admin changes will only be allowed in dev environments (determined by your ENVIRONMENT setting in your .env file).

The root cause of this issue is that you tried updating directly on a production/staging site, which is discouraged for exactly the reason you encountered (updates potentially breaking something on a live site). The encouraged workflow for updating Craft 3 sites would be as follows:

  1. Test the update in your local development environment and make sure everything works. Update any custom code if necessary.
  2. Commit your composer.json and composer.lock file as well as the config/ directory and any other adjustments you made to your Git repository.
  3. On the staging/production site, pull down the changes to your production site. Then run composer install, php craft project-config/apply and php craft migrate/all to update the dependencies and sync up your database to the latest version.

This ensures updates go smooth and you don't encounter any unexpected errors while updating.

Take a look at the following resources to learn more about this workflow:

1
  • 1
    Thanks for the help
    – mitrol
    Commented Jul 14, 2021 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.