fix(worktree): copy .envrcs/.env.* dotenv fragments into new worktrees - #138
Merged
Conversation
The devcontainer overlay copied .envrcs/.envrc.user into a new worktree but not the dotenv fragments a .envrc.user loads with `dotenv_if_exists`, so the worktree sourced a file that wasn't there and lost those vars silently. projects/xorq/ and projects/xorq-desktop/ already list `.envrcs/.env.*` for exactly this; the pattern doesn't re-match `.envrc.*`, so nothing already copied changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
projects/devcontainer/worktree-copies.txtcopied.envrcs/.envrc.userinto anew worktree but not the dotenv fragments a
.envrc.userloads withdotenv_if_exists(e.g..envrcs/.env.user.devcontainer). The worktree got thedirenv fragment and then sourced a file that wasn't there — silently, because
_if_existsdoesn't complain — so those vars were simply absent in every newworktree.
Fix
Add
.envrcs/.env.*to the overlay's copy list.projects/xorq/andprojects/xorq-desktop/already carry exactly this line; the devcontaineroverlay was the copy that didn't get it — the "guarded, but too narrowly for a
copy that propagates" class in CLAUDE.md's Conventions.
The pattern does not re-match
.envrc.*(the 5th character there isr, not.), so nothing already on the list changes behaviour. Verified against a realnullglobexpansion in the main checkout: it matches.envrcs/.env.user.devcontainerand nothing else.Notes
new-worktree.setup-worktreeonly createswhat's missing, so re-running it (or
devcontainer up) in an existingworktree picks the file up.
projects/xorq-style/has the same omission and is deliberately left out ofscope here.
🤖 Generated with Claude Code