Open garrett-hopper opened 2 years ago
The thing about direnv
is that it changes the env vars globally (ie. for every buffer in Emacs) when you switch between buffers in different project dirs, so it probably masks what is indeed an org-mode
issue: org-mode
is failing to propagate the user's process-environment
from the source buffer to the buffer in which it runs the necessary underlying external commands. I feel like this specific case has been brought up before, but I can't find mention of it in the issues here. Ultimately the solution would be to patch org-mode
to use tricks stolen from inheritenv
, which is a package I made to handle this sort of issue. It's also possible you can use inheritenv
to patch the behaviour locally, I haven't tried it though.
I was able to resolve this by adding (advice-add 'org-babel-eval :around #'envrc-propagate-environment)
to my config
Works like a charm, thanks, @siddharthverma314!
I'll leave this open in case @purcell wants to add this to the documentation or perhaps make it automatic.
I was on the fence about including a fix for this directly in envrc.el
, but in the end I've done exactly that. Thanks folks.
I would've expected an org-babel shell block to inherit the buffer local
process-envronment
and allow me to use packages which are brought in by my.envrc
(which references ashell.nix
viause nix
). This doesn't appear to be the case.I'm guessing this is an issue on the Org side, but I don't belive it was an issue previously with
direnv
.