Skip to content

Tracked .envrc from #26005 silently overwrites contributors' local direnv config #26101

Closed

Description

@kosiew

Problem

#26005 added a tracked .envrc (use flake). Before that change .envrc was
not tracked, so contributors who use direnv kept their own local .envrc
(e.g. CARGO_TARGET_DIR, CARGO_INCREMENTAL, helper exports). Since
.envrc is a common entry in global gitignores and .git/info/exclude, many
of these files are ignored rather than untracked.

Git treats ignored files as expendable, so updating to a commit that tracks
.envrc replaces the local file without any warning:

echo 'export CARGO_TARGET_DIR=/tmp/df-target' > .envrc
echo .envrc >> .git/info/exclude
git switch main            # any commit including #26005
cat .envrc                 # -> "use flake"; local config is gone

Contributors whose .envrc is untracked but not ignored instead get
error: The following untracked working tree files would be overwritten by checkout: .envrc and have to move the file aside by hand.

Why it matters

  • Silent loss of local developer config on git pull / git switch.
  • No supported place for per-contributor direnv settings: editing the tracked
    .envrc leaves a dirty tree that blocks branch switches and is easy to
    commit by accident in a PR.
  • Contributors who do not use Nix but do use direnv now get a use flake
    .envrc they cannot use as-is.

Invariant / desired behavior

  • Nix users still get the dev shell from the tracked .envrc with no extra
    steps.
  • Contributors can keep personal direnv settings in an ignored file that git
    never overwrites, and that is loaded automatically.

Proposed direction

Use the standard direnv local-override pattern:

# .envrc
use flake
source_env_if_exists .envrc.local
# .gitignore
.envrc.local

Optionally add a short note to the
development environment guide
describing the Nix/direnv setup and .envrc.local for personal settings.

Scope

In

  • Add source_env_if_exists .envrc.local to .envrc.
  • Add .envrc.local to .gitignore.
  • Brief contributor-guide note (optional).

Out

Acceptance criteria

  • With Nix + direnv, entering the repo still loads the flake dev shell.
  • A .envrc.local in the repo root is sourced by direnv after use flake.
  • git status does not show .envrc.local, and git switch /
    git pull never modify it.

Tests / verification

  • Manual: create .envrc.local with export FOO=1, run direnv allow,
    confirm echo $FOO prints 1 and git status is clean.
  • Manual: switch between commits before and after the change; confirm
    .envrc.local is untouched.

Activity

  1. added a commit that references this issue on Oct 9, 2026
    9fc84ae
  2. added a commit that references this issue on Oct 11, 2026
    f62de06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions