Skip to content

Direnv does not unload when changing to a directory without a .envrc #15

@LeGarbage

Description

@LeGarbage

When using direnv in a shell, it automatically unloads the environment upon leaving the directory. However, this plugin does not register when a directory containing a .envrc is exited, so the environment never gets unloaded. If the new directory does contain a .envrc, the new environment is loaded and the old one unloaded at the same time.

Steps to reproduce

Create 3 directories, 2 with a .envrc and 1 without

.envrc 1:

export FOO=foo

.envrc 2:

export BAR=bar

When in directory 1, running :Direnv allow and :echo $FOO gives foo.

After running :cd to directory 2 and :Direnv allow, :echo $FOO is empty and :echo $BAR gives bar.

After running :cd to directory 3, :Direnv allow warns that there is no .envrc in the current directory. :Direnv reload does nothing, and :echo $BAR still gives bar, despite having exited the directory where it was declared.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions