Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

My .bash_env file sets several environment variables, including PATH and EMAIL, but in an Emacs session launched from the Gnome Panel (command: "/usr/bin/emacs23 %F") these variables do not have the expected values. I've run into this problem before (see this blog post). I fixed it then by sourcing .bash_env in my .xsession file. Obviously, this is no longer working.

The variables are set properly if I manually launch Emacs from a terminal. Oddly, they aren't set if I change the panel launcher to execute Emacs in a terminal (I would think this would start Bash before starting Emacs).

How can I make sure the regular Bash environment is set up for the Emacs session?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Set the environment variables in ~/.profile (and source ~/.profile from ~/.xsession if you use a .xsession). That way they will be available everywhere, because they'll be set when you log in.

~/.bash_env is not the right place for environment variables (despite the name) . (Despite its existence (that's $BASH_ENV, right?) I've yet to find a good use for it.)

When you run Emacs in a terminal, it is a subprocess of the terminal emulator. There would be no reason to have a shell in between.

share|improve this answer
    
As noted, I source ~/.bash_env from ~/.xsession. I don't see any reason ~/.profile should be any different. –  Chris Conway Nov 8 '10 at 0:26
    
@Chris: How do you log in: which display manager (gdm, kdm, …) and which session type? And what release of Ubuntu do you use? Are you sure your .xsession is actually used (that's hard to achieve on 10.04)? –  Gilles Nov 8 '10 at 0:46
    
I use gdm to log into GNOME on Ubuntu 10.04. I'm not sure that .xsession is being used (not since I upgraded to 10.04, at least; it used to be). –  Chris Conway Nov 8 '10 at 1:53
    
@Chris: With this setup, .xsession is not used. It's only used if you select a custom session, and gdm on Ubuntu 10.04 doesn't offer one (the Ubuntu folks blame the Gnome folks and vice versa). But ~/.profile is read no matter what session you choose. –  Gilles Nov 8 '10 at 2:02
    
.profile does the trick! –  Chris Conway Nov 12 '10 at 2:39

/usr/bin/zsh -c emacs worked for me.

share|improve this answer

Just add bash to your launcher command, like bash codecodecode emacs %stuff (aka, just add bash at the beginning of the line) and it should work.

share|improve this answer
    
"bash emacs %F" gives "/usr/bin/emacs: cannot execute binary file". "bash -c 'emacs %F'" doesn't set the environment variables. –  Chris Conway Nov 7 '10 at 23:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.