#1519·direnv

direnv parses comments

Author: darryloCreated Nov 21, 2025Updated Jul 31, 2026
LabelsBug

Describe the bug

direnv treats commented out variable settings as unset VAR.

To Reproduce

Let's say I have a .envrc in a subdirectory e:

bash
$ cat e/.envrc
# This is a comment export FOO=99
export BAR=bleh

So, let's set a variable FOO:

$ export FOO=test

Then if you do:

$ cd e
$ echo $FOO

$ 

The value of FOO is now unset/empty, despite the comment. I want direnv to not touch it one way or the other.

Expected behavior

direnv should not know anything about stuff in comments. It should not parse or otherwise fondle comments.

I did look in the man pages but I could not find anything that could configure this. There's also no man page on .envrc. I assume # comments are allowed (there are examples that use this in the wiki), but I couldn't find anything definitive.

Environment

OS: linux, ancient RedHat 8 (I have no choice in this) Shell: bash Direnv version: 2.35.0