direnv allow has no effect when i have a .envrc file

Created on 17 Mar 2019  ยท  5Comments  ยท  Source: direnv/direnv

Issue description

I'm running Ubuntu 18.04. This is a new installation.

When I issue the command direnv allow in a directory with a.envrc file, nothing happens:

โžœ  ts git:(master) โœ— ls .envrc 
.envrc
โžœ  ts git:(master) โœ— direnv allow .
โžœ  ts git:(master) โœ— cat .envrc    
export FOO=foo
โžœ  ts git:(master) โœ— echo $FOO

โžœ  ts git:(master) โœ— 

When there is no .envrc file, it complains though:

โžœ  Projects ls .envrc     
ls: cannot access '.envrc': No such file or directory
โžœ  Projects direnv allow .
direnv: error .envrc file not found

I've install direnv from apt-get and added the following line to .zshrc:

# direnv
eval "$(direnv hook bash)"

Steps to reproduce

New installation. install from apt-get and follow instructions

Technical details

  • direnv version:v2.15.0
  • OS release: Ubuntu 18.04

Most helpful comment

@coulonxyz the hook is shell-specific, so it should be eval "$(direnv hook zsh)" bash => zsh

All 5 comments

Well, it works with bash but not zsh... even if I have do the eval "manually", nothing happens when i get in the directory or type direnv allow.

@coulonxyz the hook is shell-specific, so it should be eval "$(direnv hook zsh)" bash => zsh

@coulonxyz, it is also explained in this section.

oh my. What an idiot. Thanks a lot.

it happens to the best of us :)

Was this page helpful?
0 / 5 - 0 ratings