direnv does not work when iTerm2 shell integration is installed

Created on 28 Sep 2018  路  5Comments  路  Source: direnv/direnv

Issue description

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

Steps to reproduce

  1. Install iTerm2 shell integration
  2. Go to some directory that has .envrc
  3. Try going outside of the directory

Technical details

  • direnv version: v2.17.0
  • OS release: Mac OS High Sierra 10.13.16

I 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

Most helpful comment

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikepqr picture mikepqr  路  5Comments

jandudulski picture jandudulski  路  3Comments

amir20 picture amir20  路  7Comments

NorthIsUp picture NorthIsUp  路  4Comments

fschuindt picture fschuindt  路  3Comments