bash not working correctly with org-babel on remote server

386 Views Asked by At

The title is maybe too vague and too specific at the same time, so here is a more precise description.

I opened a remote file in Emacs with Tramp, and I wrote some org-babel blocks with bash headers, and it seemed that bash had been loaded, because when I do echo $0 I got bash as return value. However I'm not sure .bashrc is properly loaded, because I had configured conda in my .bashrc file but when I do which conda, the block returned nothing, and a Babel error buffer popped up. So I guess bash was using some wrong configuration?

I also tried which git, since Git is not configured in the .bashrc file, I've gotten the correct return. And I've also run the same code blocks on my local machine, and on the remote machine but in the inferior bash shell, both worked as expected.

Here are the commands I've run and the results I'm getting. The PATH variable has different values when run in a orgbabel block and when run in the inferior shell.

#+begin_src bash
echo $0
#+end_src

#+RESULTS:
: bash

#+begin_src bash
which conda
#+end_src

#+RESULTS:

#+begin_src bash
. ~/.bashrc
which conda
#+end_src

#+RESULTS:

#+begin_src bash
which git
#+end_src

#+RESULTS:
: /usr/bin/git

#+begin_src bash
echo $PATH
#+end_src

#+RESULTS:
: /bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

The conda folder is not in PATH. However in the inferior bash shell when I run echo $PATH I got a different result (path to conda is included so I guess the rc file is properly sourced).

/home/bins/autodockvina/bin:/home/bins/ADFRsuite_x86_64Linux_1.0/bin:/usr/local/cuda-11.1/bin:/home/bins:/root/anaconda3/bin:/root/anaconda3/bin:/usr/local/cuda-11.0/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin

So I guess the .bashrc file is not properly sourced in the orgbabel blocks?

I should probably add that I'm not quite sure how the different headers for shell blocks work, like shell, sh, and bash, etc.

0

There are 0 best solutions below