From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marius Hofert Newsgroups: gmane.emacs.help Subject: Re: Emacs on Mac 10.7 (Lion): how to get PATH as in terminal? Date: Sun, 23 Oct 2011 23:57:37 +0200 Message-ID: References: <89B4BD3D-602B-4B69-961E-2567B30B916B@math.ethz.ch> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1319407074 26592 80.91.229.12 (23 Oct 2011 21:57:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 23 Oct 2011 21:57:54 +0000 (UTC) Cc: Emacs help To: Perry Smith Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 23 23:57:48 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RI639-0007bL-Rx for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Oct 2011 23:57:48 +0200 Original-Received: from localhost ([::1]:47544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RI639-0005Vz-IV for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Oct 2011 17:57:47 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RI635-0005Vi-6q for help-gnu-emacs@gnu.org; Sun, 23 Oct 2011 17:57:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RI633-0005yB-7Z for help-gnu-emacs@gnu.org; Sun, 23 Oct 2011 17:57:43 -0400 Original-Received: from edge10.ethz.ch ([82.130.75.186]:35748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RI632-0005xz-Th for help-gnu-emacs@gnu.org; Sun, 23 Oct 2011 17:57:41 -0400 Original-Received: from CAS11.d.ethz.ch (172.31.38.211) by edge10.ethz.ch (82.130.75.186) with Microsoft SMTP Server (TLS) id 14.1.339.1; Sun, 23 Oct 2011 23:57:37 +0200 Original-Received: from 80-218-247-21.dclient.hispeed.ch (80.218.247.21) by CAS11.d.ethz.ch (172.31.38.211) with Microsoft SMTP Server (TLS) id 14.1.339.1; Sun, 23 Oct 2011 23:57:37 +0200 In-Reply-To: X-Mailer: Apple Mail (2.1251.1) X-Originating-IP: [80.218.247.21] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.130.75.186 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82628 Archived-At: On 2011-10-23, at 23:17 , Perry Smith wrote: >=20 > On Oct 23, 2011, at 3:58 PM, Marius Hofert wrote: >=20 >> Hi, >>=20 >> 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 >>=20 >> Question: How do I get the same PATH in emacs than in the terminal? >>=20 >> Trials: >>=20 >> 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) >>=20 >> 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") >>=20 >> 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"))) >=20 > I did not download the emacs that you did and dig around so I am sorta = half guessing. >=20 > Recently while dinking with rvm, I discovered that bash is not being = started with --login. >=20 > 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. Dear Perry, thanks a lot for helping.=20 >=20 > 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. =20 sorry, I should have put this in earlier. So here is my /etc/profile = [you still see the defaults write... from one of my trials]: ### /etc/profile ### # System-wide .profile for sh(1) if [ -x /usr/libexec/path_helper ]; then eval `/usr/libexec/path_helper -s` defaults write $HOME/.MacOSX/environment PATH "$PATH" fi if [ "${BASH-no}" !=3D "no" ]; then [ -r /etc/bashrc ] && . /etc/bashrc fi ############### Here is ~/.profile [the last export is to call the same emacs when = typing "emacs" in the Mac's terminal; otherwise, the preinstalled (old) = emacs version is called]: ### ~/.profile ### [ -f ~/.bashrc ] && . ~/.bashrc; # MacPorts Installer addition on 2011-09-30_at_10:26:19: adding an = appropriate PATH variable for use with MacPorts. export PATH=3D$PATH:/opt/local/bin:/opt/local/sbin # Finished adapting your PATH environment variable for use with = MacPorts. # make /Applications/Emacs.app/Contents/MacOS/emacs available when = calling "emacs" export PATH=3D/Applications/Emacs.app/Contents/MacOS/:$PATH ############### > If these parts are in the profile but > not in your .bashrc, then we are likely on the right track. My .bashrc only contains some aliases and export LC_CTYPE=3Den_US.UTF-8=20= >=20 > 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. Thanks for the hint!!! I found this (see = http://www-stat.wharton.upenn.edu/~buja/STAT-540/.emacs): (setq explicit-bash-args (list "--login" "-i")) I put it into .emacs and started emacs again. M-x shell now shows = precisely the same PATH as in the terminal. The only thing I'm wondering is: If this is really the perfect solution, = why is it not mentioned on http://www.emacswiki.org/emacs/EmacsApp ? It = seems to be much simpler than the other solutions posted, and (as I = wrote) the other solutions even did not work for me.=20 Cheers, Marius >=20 > 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. >=20 > Hope this helps, > pedz >=20