* Command not found when using Org + Guix + envrc.el
@ 2023-04-16 14:56 Fabio Natali
2023-04-16 16:21 ` Adolfo De Unanue
2023-04-17 10:35 ` Ihor Radchenko
0 siblings, 2 replies; 5+ messages in thread
From: Fabio Natali @ 2023-04-16 14:56 UTC (permalink / raw)
To: emacs-orgmode
Hi!
I tend to set up my literate programming projects with:
- 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
It's a great setup and I'm very grateful to the above projects, but
there are a few corner cases where things don't work as expected.
For instance:
- Define a Guix environment that includes Python (Python not being
installed on the system otherwise)
- Create an envrc file that activates the Guix environment, e.g. via
~eval "$(guix shell --search-paths --manifest="$1")~
- In the same folder, create an Org file with a Python block
The block is evaluated correctly when a new Emacs instance is launched
from within the folder, and therefore from within the activated
environment.
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
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
Things work fine when manually setting =org-babel-python-command=, but
hardcoding the Guix store path is clearly inconvenient, to start with
it'd require constant update.
#+begin_quote
(setq-local org-babel-python-command "/gnu/store/...")
#+end_quote
Does anyone have any idea on how to investigate this further? I'm still
unsure whether this may have to do with envrc.el, Org Babel, or possibly
with some quirks in my configuration.
Thanks, cheers, Fabio.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command not found when using Org + Guix + envrc.el
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
1 sibling, 1 reply; 5+ messages in thread
From: Adolfo De Unanue @ 2023-04-16 16:21 UTC (permalink / raw)
To: Ruijie Yu
I am facing the same problem, hopefully some one can help us
- A
On Sun, Apr 16, 2023, at 08:56, Fabio Natali wrote:
> Hi!
>
> I tend to set up my literate programming projects with:
>
> - 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
>
> It's a great setup and I'm very grateful to the above projects, but
> there are a few corner cases where things don't work as expected.
>
> For instance:
>
> - Define a Guix environment that includes Python (Python not being
> installed on the system otherwise)
> - Create an envrc file that activates the Guix environment, e.g. via
> ~eval "$(guix shell --search-paths --manifest="$1")~
> - In the same folder, create an Org file with a Python block
>
> The block is evaluated correctly when a new Emacs instance is launched
> from within the folder, and therefore from within the activated
> environment.
>
> 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
>
> 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
>
> Things work fine when manually setting =org-babel-python-command=, but
> hardcoding the Guix store path is clearly inconvenient, to start with
> it'd require constant update.
>
> #+begin_quote
> (setq-local org-babel-python-command "/gnu/store/...")
> #+end_quote
>
> Does anyone have any idea on how to investigate this further? I'm still
> unsure whether this may have to do with envrc.el, Org Babel, or possibly
> with some quirks in my configuration.
>
> Thanks, cheers, Fabio.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command not found when using Org + Guix + envrc.el
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-17 10:35 ` Ihor Radchenko
2023-04-18 15:34 ` Fabio Natali
1 sibling, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-04-17 10:35 UTC (permalink / raw)
To: Fabio Natali; +Cc: emacs-orgmode
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command not found when using Org + Guix + envrc.el
2023-04-17 10:35 ` Ihor Radchenko
@ 2023-04-18 15:34 ` Fabio Natali
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Natali @ 2023-04-18 15:34 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On 2023-04-17, 10:35 +0000, Ihor Radchenko <yantar92@posteo.net> wrote:
> 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.
Hi Ihor,
Thanks for getting back to me.
The project's author got in touch pointing out that I was using an
out-of-date version of the software.
As a matter of fact the version of envrc.el available via my distro
(Guix) was a bit behind, but this is now fixed. I can confirm this is no
longer an issue with version 0.5 of envrc.el.
Thanks for helping, all best, Fabio.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Command not found when using Org + Guix + envrc.el
2023-04-16 16:21 ` Adolfo De Unanue
@ 2023-04-18 15:38 ` Fabio Natali
0 siblings, 0 replies; 5+ messages in thread
From: Fabio Natali @ 2023-04-18 15:38 UTC (permalink / raw)
To: Adolfo De Unanue; +Cc: emacs-orgmode
On 2023-04-16, 10:21 -0600, "Adolfo De Unanue" <adolfo+org@unanue.mx> wrote:
> I am facing the same problem, hopefully some one can help us
Hi Adolfo, thanks for letting me know. It's always (somewhat) reassuring
to know that others are facing the same problem.
Good news: my issue is solved on version 0.5 of envrc.el - if you're
also on Guix, a 'guix pull && guix upgrade' might fix your problem too!
Best, cheers, Fabio.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-18 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2023-04-18 15:34 ` Fabio Natali
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.