direnv: direnv: error .envrc file not found after installing direnv using Snap in zsh

Issue description

I installed direnv using snap and although my .envrc file is present, I cannot load it. I am using oh-my-zsh and can successfully run the direnv command, but I get the error direnv: error .envrc file not found when I try allow or reload even though my .envrc file is definitely there.

Steps to reproduce

  • Install direnv using snap install direnv
  • Create a .envrc file
  • Try to load it.

Technical details

  • direnv version: 2.18.2
  • OS release: Ubuntu 18.04

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 34 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@ipolyzos I forgot to mention that I tried that. I did figure out what the issue was though: I had added the eval to the bottom of my dotfiles configuration that wasn’t loading correctly. I’m now getting this error however:

direnv: error .envrc is blocked. Run `direnv allow` to approve its content.

And when I run direnv allow .envrc I get this:

direnv: error .envrc file not found
direnv: error .envrc is blocked. Run `direnv allow` to approve its content. 

Any idea what the deal with that is?

I installed direnv from snap and, when I run direnv hook zsh the response points to:

/snap/direnv/54/bin/direnv

But, when I run which direnv it points to:

/var/lib/snapd/snap/bin/direnv

Then, on my ~/.zshrc I written the following, instead of the recomended eval $(direnv hook zsh)

_direnv_hook() {
  # eval "$("/snap/direnv/54/bin/direnv" export zsh)";
  eval "$("/var/lib/snapd/snap/bin/direnv" export zsh)";
}
typeset -ag precmd_functions;
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
  precmd_functions+=_direnv_hook;
fi

And it worked.

@RobRoseKnows if you please add the following line at the end of the ~/.zshrc file:

eval “$(direnv hook zsh)”

as per the instructions on https://direnv.net/

Yeah I don’t use the snap anymore tbh. I just installed it from the releases. I would remove the snap from the README though.

The same issue in bash on Ubuntu 20.04. direnv allow works with version installed over sudo apt install direnv and doesn’t work with snap package.

  • snap direnv: v2.18.2
  • apt direnv: v2.21.2

Hi @RobRoseKnows , the snap has been fixed using classic confinment. I am working with the snapcraft team to allow it in the officially store but takes some time. Till it get available, you can build and use it using the source at https://github.com/ipolyzos/direnv-snap