0

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 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 at 16:00
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

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.