[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs on Mac 10.7 (Lion): how to get PATH as in terminal?
From: |
Perry Smith |
Subject: |
Re: Emacs on Mac 10.7 (Lion): how to get PATH as in terminal? |
Date: |
Sun, 23 Oct 2011 16:17:53 -0500 |
On Oct 23, 2011, at 3:58 PM, Marius Hofert wrote:
> Hi,
>
> I know this is an old problem, but I still couldn't figure it out with the
> tricks I found.
> I work with the emacs 23.3 on Mac OS X 10.7.2 (Lion), installed from
> http://emacsformacosx.com/
> When I open a shell with M-x shell and type echo $PATH, I get:
> /usr/bin:/bin:/usr/sbin:/sbin
> When I do the same in Mac's Terminal, I get:
> /Applications/Emacs.app/Contents/MacOS/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:/opt/local/bin:/opt/local/sbin
>
> Question: How do I get the same PATH in emacs than in the terminal?
>
> Trials:
>
> 1) fixpath.el:
> (add-to-list 'load-path "~/.emacs.d/fixpath"); see
> https://svn.fsg.ulaval.ca/svn-pub/vgoulet/emacs-modified/macos/tags/Emacs-23.3-modified-3/fixpath.el
> (require 'fixpath)
>
> 2) emacs wiki (http://www.emacswiki.org/emacs/EmacsApp#toc2)
> ;; add "defaults..." to /etc/profile:
> if [ -x /usr/libexec/path_helper ]; then
> eval `/usr/libexec/path_helper -s`
> defaults write $HOME/.MacOSX/environment PATH "$PATH"
> fi
> ;; add the following to .emacs:
> (add-to-list 'exec-path "/usr/bin")
>
> 3) another solution posted on the emacs wiki page:
> ;; read in PATH from .bashrc (and add at least those directories)
> ;; see http://www.emacswiki.org/emacs/EmacsApp#toc5
> (if (not (getenv "TERM_PROGRAM"))
> (setenv "PATH"
> (shell-command-to-string "source $HOME/.bashrc && printf $PATH")))
I did not download the emacs that you did and dig around so I am sorta half
guessing.
Recently while dinking with rvm, I discovered that bash is not being started
with --login.
Since the M-x shell has fewer parts in its path, I would suspect that the
additional
paths are being specified in /etc/profile. Without bash thinking it is a login
shell,
/etc/profile is not being sourced. One way is to start it with a - as the
first character in
arg0. The other way is to start it with --login.
To explore if this is right: find where the parts for longer path are being
set. One
choice is /etc/profile, another is your ~/.profile. If these parts are in the
profile but
not in your .bashrc, then we are likely on the right track.
If that is the case, then review explicit-bash-args. You can customize them
and add --login
see if that works. I'm a bit surprised this isn't done in the stock version of
the code.
If you have a .profile,.bash_profile,
or .bashrc, you can echo the path at the very top of each and open a new term
window. This will
tell you where / how PATH is being set as it goes through your sequence of
login scripts.
Hope this helps,
pedz