{"record":{"id":"ed5f75c88c626f47","repo":"getgrav/grav","slug":"could-not-update-system-configuration-for-twig-com","errorCode":null,"errorMessage":"Could not update system configuration for Twig compatibility settings","messagePattern":"Could not update system configuration for Twig compatibility settings","errorType":"exception","errorClass":"InstallException","httpStatus":null,"severity":"error","filePath":"system/src/Grav/Installer/updates/1.8.0_2025-09-21_0.php","lineNumber":31,"sourceCode":"                $yaml = YamlUpdater::instance(GRAV_ROOT . '/user/config/system.yaml');\n\n                if ($yaml->exists('strict_mode.twig_compat')) {\n                    $value = $yaml->get('strict_mode.twig_compat');\n                    $yaml->undefine('strict_mode.twig_compat');\n                    $yaml->define('strict_mode.twig2_compat', $value);\n                }\n\n                if (!$yaml->exists('strict_mode.twig2_compat')) {\n                    $yaml->define('strict_mode.twig2_compat', false);\n                }\n\n                if (!$yaml->exists('strict_mode.twig3_compat')) {\n                    $yaml->define('strict_mode.twig3_compat', true);\n                }\n\n                $yaml->save();\n            } catch (\\Exception $e) {\n                throw new InstallException('Could not update system configuration for Twig compatibility settings', $e);\n            }\n        }\n];\n","sourceCodeStart":13,"sourceCodeEnd":35,"githubUrl":"https://github.com/getgrav/grav/blob/6040efed04efa69b8209448ed81308e7c24147c2/system/src/Grav/Installer/updates/1.8.0_2025-09-21_0.php#L13-L35","documentation":"Postflight hook of a Grav 1.8.0 update: it defines Twig compatibility defaults in user/config/system.yaml only when the keys are absent (strict_mode.twig2_compat: false, strict_mode.twig3_compat: true among others) and saves via YamlUpdater. Any Exception during that read-modify-write is rethrown as InstallException 'Could not update system configuration for Twig compatibility settings', with the original exception chained for the real cause.","triggerScenarios":"user/config/system.yaml unwritable by the upgrading user; the file containing YAML fragments the updater fails to parse; concurrent writes (another admin saving config mid-upgrade); disk full during save.","commonSituations":"Ownership mismatch between CLI upgrade user and web-server user; hand-edited or symlinked system.yaml; hosting with immutable config mounts.","solutions":["Make user/config/system.yaml writable by the account running direct-install and retry — the defines are guarded by exists() so re-running is safe","Verify the file parses as valid YAML and fix/restore it if not","Check the chained previous-exception message in the trace for the precise I/O error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"$file = GRAV_ROOT . '/user/config/system.yaml';\nif (file_exists($file) && !is_writable($file)) {\n    throw new \\RuntimeException(\"{$file} must be writable during the upgrade\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Install::instance()->run();\n} catch (InstallException $e) {\n    if (str_contains($e->getMessage(), 'Twig compatibility settings')) {\n        // Config write failed post-file-copy; fix permissions and re-run direct-install\n        // (the define() calls are exists()-guarded, so the retry converges)\n        chmod(GRAV_ROOT . '/user/config/system.yaml', 0664);\n    }\n}","preventionTips":["Ensure user/config ownership matches the upgrade user before running gpm","Validate system.yaml parses cleanly prior to upgrading","Re-running direct-install is safe — keys are only defined when absent"],"tags":["installer","yaml","configuration","twig","filesystem-permissions"],"backgroundTag":"config-file-write-failed","analyzedSha":"6040efed04efa69b8209448ed81308e7c24147c2","analyzedAt":"2026-08-17T05:07:31.593Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}