emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Fabio Natali <me@fabionatali.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Command not found when using Org + Guix + envrc.el
Date: Mon, 17 Apr 2023 10:35:50 +0000	[thread overview]
Message-ID: <871qkin6d5.fsf@localhost> (raw)
In-Reply-To: <877cubri3r.fsf@reckondigital.com>

Fabio Natali <me@fabionatali.com> writes:

> - Emacs and Org
> - Guix, to install the dependencies and create a development environment
> - direnv, to automatically load the Guix environment
> - envrc.el, to use direnv from Emacs
> ...
> However, things don't work as expected when using emacsclient with an
> existing Emacs server. Thanks to envrc.el the Guix environment gets
> apparently activated in the buffer, as confirmed by the envrc flag in
> the modeline and by the output of =(getenv "PATH")=. However, evaluating
> the block results in the following error:
>
> #+begin_quote
> /bin/bash: line 1: python: command not found
> [ Babel evaluation exited with code 127 ]
> #+end_quote

An ugly workaround could be using :python header argument to explicitly
set the python path.

Org babel uses a temporary buffer + `process-file' to evaluate code
blocks with no session. The current directory is being set by
let-binding `default-directory'. You can look into
`org-babel-execute-src-block' (sets `default-directory') ->
"(funcall cmd body params)" -> `org-babel-execute:python' ->
`org-babel-python-evaluate' ->
`org-babel-python-evaluate-external-process' -> `org-babel-eval' ->
`org-babel--shell-command-on-region' -> `process-file' call chain and
check where the envrc settings get lost.

I am unsure how and why the Org's approach is not working together with
envrc.el. It might be helpful to add envrc devs into the loop or debug
things yourself.

> Tangentially, if the block's header includes =:session=, as in
> =#+begin_src python :session=, then the error is slightly different and
> is displayed in the minibuffer as opposed to a separate buffer:
>
> #+begin_quote
> make-process--with-editor-process-filter: Searching for program: No such file or directory, python
> #+end_quote

This looks like "with-editor" package doing something funny. Not Org.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  parent reply	other threads:[~2023-04-17 10:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-16 14:56 Command not found when using Org + Guix + envrc.el Fabio Natali
2023-04-16 16:21 ` Adolfo De Unanue
2023-04-18 15:38   ` Fabio Natali
2023-04-17 10:35 ` Ihor Radchenko [this message]
2023-04-18 15:34   ` Fabio Natali

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=871qkin6d5.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=me@fabionatali.com \
    /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).