direnv: direnv: error .envrc or .env file not found
Describe the bug
Since the latest upgrade direnv won’t load my .env
files anymore.
To Reproduce Steps to reproduce the behavior:
- Upgrade to latest version
- Try to use direnv
Expected behavior
I was expecting my .env
files to be loaded
Environment
- OS: macOS latest
- Shell: fish
- Direnv version: 2.31.0
Additional context
direnv allow .env
direnv: error .envrc or .env file not found
The file is there but it won’t load. Someone said I now need to use fish syntax in my .env file which for shared project configuration in a multi-user repository just isn’t feasible. direnv ends up being completely unusable unfortunately. Even if I move the changes to a .envrc
they aren’t loaded.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 11
- Comments: 15 (5 by maintainers)
Commits related to this issue
- (direnv) Enable loading of .env files Direnv added a setting to opt in to loading .env files alongside .envrc files, which caused a regression in behavior for those who were relying on this functiona... — committed to emilford/dotfiles by emilford 2 years ago
- Clarify handling of .env files Follow-up on direnv#845 and direnv#911: resolves direnv#916 This commit simply updates the error messages and documentation to more accurately reflect the current opt-... — committed to doctaphred/direnv by doctaphred 2 years ago
- Clarify handling of .env files (#941) Follow-up on direnv#845 and direnv#911: resolves direnv#916 This commit simply updates the error messages and documentation to more accurately reflect the cu... — committed to direnv/direnv by doctaphred 2 years ago
This is a very frustrating issue.
direnv
updates, it silently doesn’t load the environment variables..env
file and noticing thatdirenv
isn’t asking you to rundirenv allow
any more). The error message still saysdirenv: error .envrc or .env file not found
, even though I’m staring at my .env file in the same folder and there are no weird permissions on it.There’s zero indication that a default value changed behind the scenes, for those of us that come to rely on this tool.
I think this ought to be made more prominent in the docs or even the homepage. I’m willing to bet most Mac users are going to run into this and some may not make it so far as this issue before giving up. I almost did
Unfortunately, I had to make that feature optional as it was breaking back-compat for most users.
There is a new config option that you can use to toggle that feature back on: https://direnv.net/man/direnv.toml.1.html#codeloaddotenvcode
The configuration should be added to
~/.config/direnv/direnv.toml
This should’ve been a major version bump.
I also spend some time today trying to figure out why direnv had stopped working for me.
Creating a config file as described above with the load_dotenv value reenabled the previous functionality (for me at least).
Yeah, sorry about the back-and-forth. I made a mistake. The point on the error message is also a good one if anybody wants to send a PR?
Typo, original message fixed.
it was
.envrc
for me, notenvrc
@doctaphred Much appreciated, I think this will be a great solution to the complaint I raised earlier. I don’t read/write Go either, so I can’t comment on the PR, but the language looks perfect.
Perfect, thanks a lot 😃 Just waiting on the CI to get green and then it can be merged.