direnv/direnv · error

.envrc not found

Error message

.envrc not found

What it means

`direnv reload` re-runs the .envrc for the current directory. Before doing so it calls config.FindRC(); if no .envrc (or .env) can be located in the current directory or its ancestors, direnv returns '.envrc not found' since there is nothing to reload.

Source

Thrown at internal/cmd/cmd_reload.go:17

package cmd

import (
	"fmt"
)

// CmdReload is `direnv reload`
var CmdReload = &Cmd{
	Name: "reload",
	Desc: "Triggers an env reload",
	Action: actionWithConfig(func(_ Env, _ []string, config *Config) error {
		foundRC, err := config.FindRC()
		if err != nil {
			return err
		}
		if foundRC == nil {
			return fmt.Errorf(".envrc not found")
		}

		if foundRC.Allowed() == Denied {
			return fmt.Errorf(notAllowed, foundRC.Path())
		}

		return foundRC.Touch()
	}),
}

View on GitHub (pinned to b00e451f54)

Solutions

  1. cd to the project directory that contains the .envrc (or a subdirectory of it)
  2. Create the file: `echo 'PATH=$PWD/bin' > .envrc && direnv allow`
  3. Check the filename spelling is exactly `.envrc`
  4. Verify with `direnv status` which RC file direnv expects for the current directory

Example fix

// before
cd /tmp && direnv reload   # no .envrc here
// after
cd ~/myproject && direnv reload
Defensive patterns

Strategy: validation

Validate before calling

[ -f .envrc ] || { echo "no .envrc in $(pwd)" >&2; exit 1; }
direnv reload

Try / catch

if ! direnv reload 2>&1 | grep -q '.envrc not found'; then :; else echo "cd to your project first" >&2; fi

Prevention

When it happens

Trigger: Running `direnv reload` in a directory with no .envrc/.env file anywhere up the tree, or while cwd is outside the project, or the RC file was deleted/renamed.

Common situations: Running reload from a subdirectory after moving the .envrc, forgetting to create the .envrc initially, typos in the filename (.envrrc, envrc), or running from a temp/other directory in a terminal.

Related errors


AI-assisted analysis of direnv/direnv@b00e451f54 (2026-09-05). Data as JSON: /api/errors/8218b3835bae1592. Report an issue: GitHub.