all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* inherit the path environment from .bash_profile (Mac OS 10.5)
@ 2010-08-06  3:15 Z
  2010-08-06 14:00 ` Jim Crossley
  0 siblings, 1 reply; 12+ messages in thread
From: Z @ 2010-08-06  3:15 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 550 bytes --]

Hello,

Is there a way to inherit the path environments of .bash_profile, when we
lance emacs directly from the dock of Macs?

In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock
(which is the icons list normally at the bottom of the screen) . Then, if I
invoke a shell from within emacs, it does not inherit the path environment
defined at .bash_profile !

So in my case, how can I achieve this inheritance of path environments?
Maybe it suffices to add something at the initialization file .emacs?

Thank you for your ideas.

Z.

[-- Attachment #2: Type: text/html, Size: 614 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Inherit the path environment from .bash_profile (Mac OS 10.5)
@ 2010-08-06  3:17 Z
  2010-08-06  8:47 ` Peter Dyballa
  2010-08-06 12:09 ` Andrea Crotti
  0 siblings, 2 replies; 12+ messages in thread
From: Z @ 2010-08-06  3:17 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

Hello,

Is there a way to inherit the path environments of .bash_profile, when we
lance emacs directly from the dock of Macs?

In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock
(which is the icons list normally at the bottom of the screen) . Then, if I
invoke a shell from within emacs, it does not inherit the path environment
defined at .bash_profile !

So in my case, how can I achieve this inheritance of path environments?
Maybe it suffices to add something at the initialization file .emacs?

Thank you for your ideas.

Z.






-- 
Zhoulai FU

INRIA Rennes - Bretagne Atlantique
Campus Universitaire de Beaulieu
35042 RENNES Cedex - FRANCE

[-- Attachment #2: Type: text/html, Size: 846 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: inherit the path environment from .bash_profile (Mac OS 10.5)
       [not found] <mailman.0.1281064508.32647.help-gnu-emacs@gnu.org>
@ 2010-08-06  5:58 ` Tim X
  2010-08-06  7:15 ` Xah Lee
  1 sibling, 0 replies; 12+ messages in thread
From: Tim X @ 2010-08-06  5:58 UTC (permalink / raw)
  To: help-gnu-emacs

Z <zell08v@orange.fr> writes:

> Hello,
>
> Is there a way to inherit the path environments of .bash_profile, when we
> lance emacs directly from the dock of Macs?
>
> In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock (which
> is the icons list normally at the bottom of the screen) . Then, if I invoke a
> shell from within emacs, it does not inherit the path environment defined at
> .bash_profile !
>
> So in my case, how can I achieve this inheritance of path environments? Maybe
> it suffices to add something at the initialization file .emacs?
>
> Thank you for your ideas.
>

I suspect the problem is similar to the one which can occur from X
windows when starting a program from a launcher etc. The issue arrives
because the windowing system is started within a non-login shell, which
emans the shell profile file is not run and therefore, none of the env
settings, such as path, are inherited by any of the sub-processes run. 

There are a couple of solutions.

1. Under X, you can add the switch to make the parent process that runs
the window manager a login shell. Not sure how this can be done under
OSX. Under X, it usually involdes making the sh/bash shell that runs
your xsession a login shell with -l or --login.

2. The docs to shell mode have the following sections

If a file `~/.emacs_SHELLNAME' exists, or `~/.emacs.d/init_SHELLNAME.sh',
it is given as initial input (but this may be lost, due to a timing
error, if the shell discards input when it starts up).

and 

The shell file name (sans directories) is used to make a symbol name
such as `explicit-csh-args'.  If that symbol is a variable,
its value is used as a list of arguments when invoking the shell.
Otherwise, one argument `-i' is passed to the shell.

You could try putting 

source ~/.bash_profile 

into ~/.emacs_bash or possibly, putting 

(defvar explicit_bash_args "-li")

could work.

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: inherit the path environment from .bash_profile (Mac OS 10.5)
       [not found] <mailman.0.1281064508.32647.help-gnu-emacs@gnu.org>
  2010-08-06  5:58 ` inherit " Tim X
@ 2010-08-06  7:15 ` Xah Lee
  1 sibling, 0 replies; 12+ messages in thread
From: Xah Lee @ 2010-08-06  7:15 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 5, 8:15 pm, Z <zell...@orange.fr> wrote:
> Hello,
>
> Is there a way to inherit the path environments of .bash_profile, when we
> lance emacs directly from the dock of Macs?
>
> In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock
> (which is the icons list normally at the bottom of the screen) . Then, if I
> invoke a shell from within emacs, it does not inherit the path environment
> defined at .bash_profile !
>
> So in my case, how can I achieve this inheritance of path environments?
> Maybe it suffices to add something at the initialization file .emacs?
>
> Thank you for your ideas.
>
> Z.

this is from my emacs init file, wrote around 2004 or so.

; Carbon Emacs doesn't inherit shell's env.  A workaround is to shart
it from shell like this: “/Applications/Emacs.app/Contents/MacOS/Emacs
&” however, exiting the shell by Ctrl+D also kills your emacs. So a
workaround is to use the nohub: “nohup /Applications/Emacs.app/
Contents/MacOS/Emacs &”.  However, Apple's Term has a feature such
that closing the window (by clicking on the Red Light or Cmd+w) kills
all processes started from it.  So, the solution is to never close
window by clicking or Cmd+w, instead, always use Ctrl+d. However, when
ssh to remote server and running “tail -f”, sometimes broken
connection causes the session to hang. So you are left with a frozen
ssh session where the remote server has disconnected. So, here you
can't use Ctrl-d to close the window. If you close the window by
clicking, then you'll kill any emacs you might have started from that
window. Hot Damn.  So, the optimal solution seems to get Carbon Emacs
to start using the Mac's GUI way of inheriting env vars by the file
“~/.MacOSX/environment.plist”. Though, that mean you gonna maintain
two sets of env vars. Shit. Therefore at the end, maybe just dup it in
elisp and forget about all quality solutions. Software Industry is
quite fucked anyway. This is peanuts. All this is due to the
motherfucking unix fucking env var system fuck. Fuck unix and fuck the
unixer's mothers.

(setenv "PATH" "/Users/xah/bin:/usr/local/bin:/opt/local/bin:/
Developer/Tools:/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/
X11R6/bin:/usr/X11R6/bin")

(setenv "MANPATH" "/usr/local/man/:/sw/share/man:/usr/share/man:/usr/
X11R6/man:/sw/lib/perl5/5.8.6/man")

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06  3:17 Inherit " Z
@ 2010-08-06  8:47 ` Peter Dyballa
  2010-08-06 14:04   ` Jim Crossley
  2010-08-06 12:09 ` Andrea Crotti
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Dyballa @ 2010-08-06  8:47 UTC (permalink / raw)
  To: Z; +Cc: help-gnu-emacs


Am 06.08.2010 um 05:17 schrieb Z:

> So in my case, how can I achieve this inheritance of path  
> environments?

Either use a shell script which launches Carbon Emacs or  
translate .bash_profile's contents into Elisp à la:

	(setenv "PATH" (concat "/some/directory" path-separator (getenv  
"PATH")))

You can save some work by first investigating the value of process- 
environment.


A different method is composing a file ~/.MacOSX/environment.plist. It  
sets the environment for all processes at boot time. Read more here: http://developer.apple.com/qa/qa2001/qa1067.html 
  (also available via Xcode on disk: /Developer/Documentation/DocSets/ 
com.apple.ADC_Reference_Library.CoreReference.docset/Contents/ 
Resources/Documents/qa/qa2001/qa1232.html).

--
Greetings

   Pete

Hard Disk, n.:
	A device that allows users to delete vast quantities of data with  
simple mnemonic commands.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
       [not found] <mailman.1.1281064641.32647.help-gnu-emacs@gnu.org>
@ 2010-08-06 12:02 ` Elena
  0 siblings, 0 replies; 12+ messages in thread
From: Elena @ 2010-08-06 12:02 UTC (permalink / raw)
  To: help-gnu-emacs

I don't now about OS X, however in Debian GNU/Linux there is a
~/.profile which both is loaded by X and is included in
~/.bash_profile. Maybe you can achieve the same in OS X.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06  3:17 Inherit " Z
  2010-08-06  8:47 ` Peter Dyballa
@ 2010-08-06 12:09 ` Andrea Crotti
  1 sibling, 0 replies; 12+ messages in thread
From: Andrea Crotti @ 2010-08-06 12:09 UTC (permalink / raw)
  To: help-gnu-emacs

Z <zell08v@orange.fr> writes:

> Hello,
> Is there a way to inherit the path environments of .bash_profile, when we
> lance emacs directly from the dock of Macs?
>
> In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock
> (which is the icons list normally at the bottom of the screen) . Then, if
> I invoke a shell from within emacs, it does not inherit the path
> environment defined at .bash_profile !
>
> So in my case, how can I achieve this inheritance of path environments?
> Maybe it suffices to add something at the initialization file .emacs?
>
> Thank you for your ideas.
> Z.

I think I also asked the same thing some time ago and didn't come out
with anything.
I solved simply launching
--8<---------------cut here---------------start------------->8---
open /Applications/Emacs.app
--8<---------------cut here---------------end--------------->8---

even though I'm quite sure there's a smarter way to do that...




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06  3:15 inherit " Z
@ 2010-08-06 14:00 ` Jim Crossley
  2010-08-06 15:36   ` Peter Dyballa
  0 siblings, 1 reply; 12+ messages in thread
From: Jim Crossley @ 2010-08-06 14:00 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Z,

Z <zell08v@orange.fr> writes:

> Is there a way to inherit the path environments of .bash_profile, when
> we lance emacs directly from the dock of Macs?

I looked long and hard for a good way of doing this, so that both GUI
and CLI apps had the same environment (path+vars), no matter how they
were started, e.g. spotlight, dock, bash, etc.

I'm sorry to report there is NO GOOD WAY to do it on a Mac.  Here's what
I ultimately ended up adding to my Emacs config:

;; Setup PATH 
(setenv "PATH" (shell-command-to-string "source ~/.bashrc; echo -n $PATH"))
;; Update exec-path with the contents of $PATH
(loop for path in (split-string (getenv "PATH") ":") do 
      (add-to-list 'exec-path path))

The above answers your question specifically about PATH.  I'll add this
bit about vars, too, since you'll eventually want it.  :)

;; Grab other environment variables
(loop for var in (split-string (shell-command-to-string "source ~/.bashrc; env")) do
      (let* ((pair (split-string var "="))
	     (key (car pair))
	     (value (cadr pair)))
	(unless (getenv key)
	  (setenv key value))))

I symlink my ~/.bashrc to ~/.bash_profile, btw.

Good luck,
Jim

>
> In fact, I am using Mac OS X 10.5. I launch carbon emacs from the dock (which
> is the icons list normally at the bottom of the screen) . Then, if I invoke a
> shell from within emacs, it does not inherit the path environment defined at
> .bash_profile !
>
> So in my case, how can I achieve this inheritance of path environments? Maybe
> it suffices to add something at the initialization file .emacs?
>
> Thank you for your ideas.
>
> Z.
>
>  




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06  8:47 ` Peter Dyballa
@ 2010-08-06 14:04   ` Jim Crossley
  2010-08-06 15:27     ` Peter Dyballa
  0 siblings, 1 reply; 12+ messages in thread
From: Jim Crossley @ 2010-08-06 14:04 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

[...]

> A different method is composing a file ~/.MacOSX/environment.plist. It
> sets the environment for all processes at boot time. Read more here:

Offtopic, sorry, but speaking of environment.plist, I was shocked to
find out there's no way to do substitution in a plist file.  Hence, you
can't define variables in terms of other variables, which makes that
file needlessly verbose and error prone.

Jim




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06 14:04   ` Jim Crossley
@ 2010-08-06 15:27     ` Peter Dyballa
  2010-08-08 17:54       ` Andrea Crotti
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Dyballa @ 2010-08-06 15:27 UTC (permalink / raw)
  To: Jim Crossley; +Cc: help-gnu-emacs


Am 06.08.2010 um 16:04 schrieb Jim Crossley:

> Peter Dyballa writes:
>
> [...]
>
>> A different method is composing a file ~/.MacOSX/environment.plist.  
>> It
>> sets the environment for all processes at boot time. Read more here:
>
> Offtopic, sorry, but speaking of environment.plist, I was shocked to
> find out there's no way to do substitution in a plist file.  Hence,  
> you
> can't define variables in terms of other variables, which makes that
> file needlessly verbose and error prone.
>


Yes. One has to be aware of what one did. OTOH, it's probably  
sufficient for a dozen *basic* settings, PATH, MANPATH, INFOPATH,  
LANG, LC_CTYPE...

--
Greetings

   Pete

Well begun is half done.
			– Optimist.
Half done is well begun.
			– Realist.
Half begun is well done.
			– Australian.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06 14:00 ` Jim Crossley
@ 2010-08-06 15:36   ` Peter Dyballa
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Dyballa @ 2010-08-06 15:36 UTC (permalink / raw)
  To: Jim Crossley; +Cc: help-gnu-emacs


Am 06.08.2010 um 16:00 schrieb Jim Crossley:

> ;; Setup PATH
> (setenv "PATH" (shell-command-to-string "source ~/.bashrc; echo -n  
> $PATH"))


You have the defaults utility which you can use inside shell RC files:

	setenv MANPATH	`defaults read ~/.MacOSX/environment MANPATH`
	export PATH=$(defaults read "${HOME}/.MacOSX/environment" PATH)

If needed! Remember that ~/.MacOSX/environment.plist is read at login  
time so that all applications launched afterwards (from Dock or via  
launch service) inherit this process environment. (On Tiger, Mac OS X  
10.4, X11 did not pass the environemnt to its X clients.) When you  
remotely log in you might need settings in your login shell's RC  
file(s). Which I can't test...

--
Greetings

   Pete

Time flies like an error – but fruit flies like a banana!
				- (almost) Groucho Marx




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Inherit the path environment from .bash_profile (Mac OS 10.5)
  2010-08-06 15:27     ` Peter Dyballa
@ 2010-08-08 17:54       ` Andrea Crotti
  0 siblings, 0 replies; 12+ messages in thread
From: Andrea Crotti @ 2010-08-08 17:54 UTC (permalink / raw)
  To: help-gnu-emacs

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

>
>
> Yes. One has to be aware of what one did. OTOH, it's probably
> sufficient for a dozen *basic* settings, PATH, MANPATH, INFOPATH,
> LANG, LC_CTYPE...

Well I don't see the reason to do that then, at worst I can create an
icon to launch that script, it's much easier and painless...




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-08-08 17:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1.1281064641.32647.help-gnu-emacs@gnu.org>
2010-08-06 12:02 ` Inherit the path environment from .bash_profile (Mac OS 10.5) Elena
     [not found] <mailman.0.1281064508.32647.help-gnu-emacs@gnu.org>
2010-08-06  5:58 ` inherit " Tim X
2010-08-06  7:15 ` Xah Lee
2010-08-06  3:17 Inherit " Z
2010-08-06  8:47 ` Peter Dyballa
2010-08-06 14:04   ` Jim Crossley
2010-08-06 15:27     ` Peter Dyballa
2010-08-08 17:54       ` Andrea Crotti
2010-08-06 12:09 ` Andrea Crotti
  -- strict thread matches above, loose matches on Subject: below --
2010-08-06  3:15 inherit " Z
2010-08-06 14:00 ` Jim Crossley
2010-08-06 15:36   ` Peter Dyballa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.