It seems that iTerm2's shell integration causes direnv to not work. After installing shell integration going into a directory that has a .envrc file won't load the envrc (calling direnv reload also does not work) and of course exiting the directory doesn't unload anything.
Interestingly if I work to run a fresh iTerm session within a directory that has a .envrc it does load it, but will not unload or load any other .envrc when going outside or into directories
.envrcdirenv version: v2.17.0I don't know if direnv has any logs that I can look into to help debug or anything. If it's believe this is more of an iTerm issue then please tell me and feel free to close the issue
Hi, do you know what shell is being used? If it's bash, can you give me the output of echo $PROMPT_COMMAND. It's possible that the iTerm integration is changing the shell hooks and discarding those used by direnv.
Moving the eval "$(direnv hook bash)" line after the iterm one should fix the issue.Searching for PROMPT_COMMAND= in https://iterm2.com/shell_integration/bash shows that they are overriding everything.
@zimbatm sorry for late reply and yup moving the PROMPT_COMMAND worked for me. Thanks for that, had no idea how to debug it so that was a great help
no problem. If you have the time it would be good to report the issue to iTerm since they are causing the problem
I've also had this issue and found adding the line _after_ the iterm2 shell integration line didn't work for me. I've raised it with the iterm2 gitlab project as suggested by @zimbatm see https://gitlab.com/gnachman/iterm2/issues/7961
I've included details of my hacky workaround in there.
Most helpful comment
Moving the
eval "$(direnv hook bash)"line after the iterm one should fix the issue.Searching forPROMPT_COMMAND=in https://iterm2.com/shell_integration/bash shows that they are overriding everything.