purcell / inheritenv

Make emacs temp buffers inherit buffer-local environment variables
43 stars 2 forks source link

Confused about `inheritenv-add-advice` #6

Open indigoviolet opened 2 years ago

indigoviolet commented 2 years ago

Perhaps related to #4 as well. I am trying to fix https://github.com/purcell/envrc/issues/12#issuecomment-770330324

I have used inheritenv-add-advice #'with-temp-buffer in my config, and I can see that this has worked:

image

But I find differing results based on whether I use C-x C-e (environment doesn't appear to be inherited) or an org-babel block (does appear to be inherited).

(exec-path) => ("/home/venky/dev/pytorch-summary/.venv/bin/" "/usr/lib/" ...)

(with-temp-buffer (exec-path)) => ("/usr/lib" ...) <--- NOTE THE MISSING .venv directory

#+begin_src emacs-lisp :results raw value code
(exec-path)
#+end_src

#+RESULTS:
#+begin_src emacs-lisp
("/home/venky/dev/pytorch-summary/.venv/bin/" "/usr/lib/" ...)
#+end_src

#+begin_src emacs-lisp :results raw value code
(with-temp-buffer (exec-path))
#+end_src

#+RESULTS:
#+begin_src emacs-lisp
("/home/venky/dev/pytorch-summary/.venv/bin/" "/usr/lib/" ...)
#+end_src

Could you please give me a pointer as to what might be going on?

purcell commented 2 years ago

I don't think you should advise with-temp-buffer — that's too big a sledgehammer, and I wouldn't expect it to be easy to debug. But I believe the org issue is that mentioned in https://github.com/purcell/envrc/issues/28, and a workaround was committed fairly recently — perhaps check your packages are up to date.