11

With emacs/eshell, the "echo $PATH" shows different paths than that of $PATH environment variable.

And I also checked that eshell doesn't read .bashrc or .profile, and I think that's the reason why the path is different.

  • What setup file does eshell read when it starts?
  • How eshell sets its PATH?
  • How to make the eshell's PATH the same as the environment variable's PATH?

ADDED

As Jérôme Radix pointed out, the PATH depends on how I start the Aquamcs.

  • When I click the button to start Aquamacs, it has different PATH.
  • When I run 'aquamacs' from the command line, it has the same PATH.
prosseek
  • 182,215
  • 215
  • 566
  • 871

3 Answers3

6
  • What setup file does eshell read when it starts?

No setup file is executed at startup. The following files are read to define the initial history and last directories :

~/.eshell/history
~/.eshell/lastdir
  • How eshell sets its PATH?

In esh-util.el, line 240 :

(defvar eshell-path-env (getenv "PATH")
  "Content of $PATH.
It might be different from \(getenv \"PATH\"\), when
`default-directory' points to a remote host.")
  • How to make the eshell's PATH the same as the environment variable's PATH?

It is the same as the PATH variable of the emacs process. I imagine that you do a echo $PATH on a shell outside emacs to compare. If PATH are differents between emacs and your shell outside emacs it is because emacs and your shell does not execute the same startup scripts.

Jérôme Radix
  • 10,285
  • 4
  • 34
  • 40
  • Can you give an example of how to start emacs, so that the bash and eshell use a `bashrc` file? Aren't their syntaxes different? How could they ever use the same file? – Zelphir Kaltstahl Feb 27 '17 at 20:27
5

Since you are on a Mac, it's important to know that GUI applications (such as Aquamacs when not opened from a terminal) get their environment from ~/.MacOSX/environment.plist, so you can make changes there. See in particular this article by Brian D Foy for a way to build this file automatically.

Sean Allred
  • 3,558
  • 3
  • 32
  • 71
Ivan Andrus
  • 5,221
  • 24
  • 31
  • I found these articles to be useful for setting up my environment.plist: http://blog.nguyenvq.com/tag/environment-plist/ – Martin Owen Aug 01 '11 at 09:57
1

By definition, echo $PATH shows the value of the PATH environment variable. The shell running inside Emacs inherits the PATH environment variable from the running Emacs process.

<EDIT> The shell running in eshell is not a separate program like bash, it's built into Emacs. Its customization is done through Emacs Lisp. In particular, when eshell starts, it runs the functions in eshell-mode-hook and loads the Lisp files in eshell-modules-list. </EDIT>

It looks like you're not setting PATH in the right configuration file. The right place would be something that's done at the start of your session. This is operating system-dependent; if you have trouble with that, ask on Super User, making sure to say what your operating system is, and if applicable indicate your login shell, desktop environment, etc.

Community
  • 1
  • 1
Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
  • M-x shell or M-x ansi-term works fine, but not with eshell. I'm almost certain eshell doesn't load .bashrc. – prosseek Sep 02 '10 at 01:57
  • @prosseek: yes, sorry, eshell doesn't run bash, so it doesn't load `.bashrc`. If you're setting `PATH` in `.bashrc`, that would explain why you're having trouble. This is one of the reasons why `.bashrc` is not the right place to set `PATH` (or any environment variable); see my last paragraph. – Gilles 'SO- stop being evil' Sep 02 '10 at 07:22