1

I have several binaries I would like to call from eshell; I'm running into not-found-in-path errors. They are callable from a normal shell.

Following the advice from the emacs wiki:

~/.emacs.d/config $ which cargo
which: no cargo in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin)
~/.emacs.d/config $ (setq exec-path (append exec-path '("/home/thor/.cargo/bin")))
("/usr/local/sbin" "/usr/local/bin" "/usr/sbin" "/usr/bin" "/sbin" "/bin" "/usr/games" "/usr/local/games" "/snap/bin" "/usr/lib/emacs/27.1/x86_64-linux-gnu" "/home/thor/.cargo/bin")
~/.emacs.d/config $ which cargo
which: no cargo in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin)
~/.emacs.d/config $ (setenv "PATH" (concat (getenv "PATH") ":/home/thor/.cargo/bin"))
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/thor/.cargo/bin
~/.emacs.d/config $ which cargo
which: no cargo in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/thor/.cargo/bin)

whereas from a normal shell:

$ which cargo
/home/thor/.cargo/bin/cargo
2
  • 1
    Do the setenv PATH before opening the shell - it does not alter the PATH in a the shell.
    – mmmmmm
    Sep 9, 2021 at 10:44
  • @mmmmmm: Please consider posting that as an answer. OP: if it solves your problem, consider accepting the answer (or wait for a better one to accept). But please check whether this question might be a duplicate (by searching). Thx.
    – Drew
    Sep 9, 2021 at 16:00

2 Answers 2

1

Your call to setenv will only change the environment in shells that are called later and not your current shell.

So the correct way is put the correct setenv in your init file(s) and then when you call eshell you will get the correct values.

As to why a normal shell finds it and emacs does not that depends on what OS you are on and how you call emacs and where you set the PATH. That is probably best as another question and give all the details - although probably a duplicate

-1

I solved it in my case by modifying the PATH variable right at the beginning of my .emacs file.

(setenv "PATH" (concat "c:/Program Files/Chez Scheme 9.5.8/bin/ta6nt;" (getenv "PATH")))

Note: this depends on the OS. The above line is for Windows, because it uses ; as a delimiter. On Unix you have to use : as a delimiter.

This works also fine to set GIT_EDITOR for Eshell.

(server-start)
(setenv "GIT_EDITOR"
        (concat "'" (getenv "emacs_dir") "/bin/emacsclient.exe'"))

I have also installed Intellij and Git should use emacsclient only, when executed by Eshell but not when executed by Intellij.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.