direnv/direnv · error
cannot allow empty path
Error message
cannot allow empty path
What it means
Raised in RC.Allow when the RC struct's allowPath field is empty. allowPath is computed as AllowDir()/sha256-of-rc-file by RCFromPath/RCFromEnv; an empty value means the RC object was constructed without a resolvable allow path (e.g. RCFromEnv failed to hash the file and returned a degenerate RC, or the RC was hand-built in tests/embedding). This is a defensive invariant guard — Allow refuses to write permission state to an unspecified location. Reached from cmdEditAction after editing.
Source
Thrown at internal/cmd/rc.go:102
err = times.Unmarshal(marshalledTimes)
if err != nil {
return nil
}
pathHash, err := pathHash(path)
if err != nil {
return nil
}
denyPath := filepath.Join(config.DenyDir(), pathHash)
return &RC{path, allowPath, denyPath, times, config}
}
// Allow grants the RC as allowed to load
func (rc *RC) Allow() (err error) {
if rc.allowPath == "" {
return fmt.Errorf("cannot allow empty path")
}
if err = os.MkdirAll(filepath.Dir(rc.allowPath), 0755); err != nil {
return
}
if err = allow(rc.path, rc.allowPath); err != nil {
return
}
if err = rc.times.Update(rc.allowPath); err != nil {
return
}
if _, err = os.Stat(rc.denyPath); err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
}
return os.Remove(rc.denyPath)
}View on GitHub (pinned to b00e451f54)
Solutions
- Construct the RC via RCFromPath/FindRC so allowPath is populated from config.AllowDir()
- If building RC manually, initialize all fields including the hashed allow path
- Check that config.DataDir is set so AllowDir() yields a non-empty base
- Report a bug if this fires during normal `direnv allow`/`direnv edit` usage — it indicates a construction bug
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/cmd/rc.go:102 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of direnv/direnv@b00e451f54 (2026-09-05).
Data as JSON: /api/errors/cca8d81b97a007b0.
Report an issue: GitHub.