emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dominik Schrempf <dominik.schrempf@gmail.com>
To: "Berry, Charles" <ccberry@health.ucsd.edu>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Org babel source blocks ignore buffer-local variables
Date: Mon, 06 Sep 2021 10:53:37 +0200	[thread overview]
Message-ID: <87lf4ajd7u.fsf@gmail.com> (raw)
In-Reply-To: <676F013F-AC22-4853-9E13-C91B92C3B59A@health.ucsd.edu>

Thank you, this solution works. May I ask about the reasons of such a
distinction?

Dominik

"Berry, Charles" <ccberry@health.ucsd.edu> writes:

>> On Sep 4, 2021, at 5:30 AM, Dominik Schrempf <dominik.schrempf@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
>
>   



  reply	other threads:[~2021-09-06  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 12:30 Org babel source blocks ignore buffer-local variables Dominik Schrempf
2021-09-04 17:14 ` Berry, Charles via General discussions about Org-mode.
2021-09-06  8:53   ` Dominik Schrempf [this message]
2021-09-06 18:32     ` Berry, Charles via General discussions about Org-mode.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lf4ajd7u.fsf@gmail.com \
    --to=dominik.schrempf@gmail.com \
    --cc=ccberry@health.ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).