Jayan
Jayan

Reputation: 18458

direnv with WSL2 - not loading files when used with source_env_if_exists

(this is to document a specific behavior that may affect users mixing windows and wsl for work)

I use a hierarchy of directories with .envrc in them to manage environment.

file content is like

export BASE_URL="url"
source_env_if_exists .terraform-state

First line works, second appears to be not doing anything. source_env_if_exists is direnv library call (https://github.com/direnv/direnv/blob/master/stdlib.sh)

Local environment is WSL2(Ubuntu), where the file is part of directory checked out on windows but used with in WSL

Upvotes: 0

Views: 1535

Answers (1)

Jayan
Jayan

Reputation: 18458

File is edited/cloned from windows leaves line ending in windows style. direnv library leaves that to bash (and does nothing) . Windows WSL - issue with carriege return · Issue #542 · direnv/direnv · GitHub has more details.

Fixing the file (using dos2linux or fresh clone from WSL2 ) worked.

Upvotes: 1

Related Questions