> On Sep 4, 2021, at 5:30 AM, Dominik Schrempf <dominik.schre...@gmail.com> > wrote: > > Hello, > > I use directory local environments with =envrc= [1], and run into trouble when > using (Bash) Org Babel source code blocks. The buffer local environment seems > to > be ignored (see the example at the bottom). > > This seems to have been discussed in the course of a GitHub issue of > =inheritenv= [2], which is pulled in by =envrc=. Also, on this mailing list, > there was a short discussion [3]. > > Do you have any thoughts on this? Is there an easy way to make Org Babel > source > blocks honor buffer local setups? > > Thank you! > Dominik > > #+name: Scratch > #+begin_src sh :exports both :results output verbatim > function path () { echo "$PATH" | tr ':' '\n'; } > path > #+end_src > > #+RESULTS: Scratch > #+begin_example > /home/dominik/Evolutionary-Biology/Scripts/nix-flakes > /home/dominik/Evolutionary-Biology/Scripts > /home/dominik/bin/nix-flakes > /home/dominik/bin > /run/wrappers/bin > /home/dominik/.nix-profile/bin > /etc/profiles/per-user/dominik/bin > /nix/var/nix/profiles/default/bin > /run/current-system/sw/bin > /nix/store/3l9lddwxz1mayaxvw8iy50ygzzfh1s1b-emacs-27.2/libexec/emacs/27.2/x86_64-pc-linux-gnu > #+end_example > > The Emacs =exec-path= variable has the following value: > > #+begin_quote > exec-path is a variable defined in ‘C source code’. > Its value is > ("/nix/store/cnxncxyghj3gfpfvng6z4l8k4hfl48wq-ghc-8.10.6-with-packages/bin/" > "/nix/store/435paza0j48aa9vgvf6r2l12nrg4ld11-patchelf-0.12/bin/"
[snip] Indeed, ~exec-path~ and ~(getenv "PATH")~ can differ. If you want to set PATH for a shell src block, you can do something like: #+begin_src sh :results output verbatim :var PATH=(mapconcat 'identity exec-path ":") echo $PATH #+end_src HTH, Chuck