Skip to content

magento2-init: add the Valkey keys when the init.env template lacks them - #20

Merged
mlaurense merged 1 commit into
mainfrom
bugfix/magento2-init-valkey-upsert
Nov 10, 2026
Merged

mlaurense merged 1 commit into
mainfrom
bugfix/magento2-init-valkey-upsert

Conversation

@marcepartment

Copy link
Copy Markdown
Collaborator

Follow-up to #19, addressing the Copilot review comment on utils/magento2-init.sh.

Problem

fetchEnvInitFile prefers a custom ~/.roll/environments/magento2/init.env or project .roll/environments/magento2/init.env over the bundled template. A custom template written before #19 has no ROLL_VALKEY or VALKEY_VERSION line, so for Magento 2.4.8 and 2.4.9 the sed substitutions in m2initWriteEnvConfig changed nothing while ROLL_REDIS was still set to 0. The project came up with no in-memory store and magento2-init failed its readiness check.

Fix

New m2initSetEnvValue sets KEY=value in .env.roll and appends the line when the file has none (without gluing it onto a last line that lacks a newline). The Valkey branch uses it for ROLL_VALKEY and VALKEY_VERSION. It writes no .env.roll.backup.* file.

Verification

With ROLL_HOME_DIR pointing at a custom template taken from before #19 (no Valkey keys):

Magento main this branch
2.4.9 ROLL_REDIS=0, no Valkey line → no store valkey:9
2.4.8-p3 same, no store valkey:8
2.4.7-p6 redis:7.2 redis:7.2 (unchanged)
  • The bundled template and a custom template without a trailing newline both produce the right .env.roll.
  • roll config conflicts is clean on the result.
  • ShellCheck is clean and .github/scripts/smoke.sh bash32 passes.

🤖 Generated with Claude Code

fetchEnvInitFile prefers a custom ~/.roll or project .roll/environments
init.env over the bundled one. A template written before Valkey existed has
no ROLL_VALKEY or VALKEY_VERSION line, so the sed substitutions changed
nothing while ROLL_REDIS was still set to 0: 2.4.8 and 2.4.9 projects came
up with no in-memory store and failed the readiness check. Set both keys
through m2initSetEnvValue, which appends a missing line.

Raised by Copilot on #19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change addressing missing Valkey settings in older custom initialization templates.

No open issues 🎉

What changed in this PR

Fixes Magento initialization with older custom init.env templates that lack Valkey keys, completing the Valkey support introduced in #19.

Changes:

  • Adds a helper to update or append environment values, handling files without a trailing newline.
  • Uses the helper for Valkey settings so Magento 2.4.8 and 2.4.9 retain an in-memory store.
  • Documents the custom-template fix in the changelog.
File Description
utils/​magento2-init.sh Adds the update-or-append helper and applies it to Valkey settings.
CHANGELOG.md Records compatibility with older custom templates missing Valkey keys.

Review effort: Balanced

@mlaurense
mlaurense merged commit fdd2268 into main Nov 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants