Skip to content

Cannot reference PWD in .env file for variable expansion #1051

@reegnz

Description

@reegnz

Describe the bug
Direnv allows for variable expansion in .env files. The PWD environment variable is however removed in the direnv process from the environment variables to not interfere with finding .envrc.

To Reproduce
Steps to reproduce the behavior:
In any folder put the following two files:

dotenv
TEST1=$PWD
TEST2=$HOME

TEST1 will be empty, while TEST2 will have expanded properly.

Expected behavior
PWD in .env files should expand to the folder the .env file resides in.

Environment

  • OS: [e.g. macOS Ventura]
  • Shell: [zsh]
  • Direnv version [e.g. 2.32.2]

Additional context
Other .env impementations don't have this issue. I've checked the following, which all seem to work as expected:
https://github.com/bkeepers/dotenv
https://github.com/motdotla/dotenv-expand

Both work as expected and expand PWD properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions