Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-07-2010, 05:59 PM   #1
LQ Newbie
Registered: Aug 2010
Posts: 4

Rep: Reputation: 0
Question Different linux initialized environments for shells vs. emacs?


I'm finalizing the the dual-boot addition that I recently completed. I've added lubuntu to the LT3114u Netbook that I use. That's done, now I'm migrating my user environment back from the Cygwin one that I've been using on Windoze, as of late. One of features that's been useful has been the global environment management possible with the windoze UI functions.

As I coded my emacs environment while 'over there' (windoze side), I included a check for the lisp library repository path environment variable EMACSLOADPATH. It is globally available when one logs in, and does not get set in any user scripts, or dot files any to do with CYGWIN or emacs.

While it has been easy enough to set EMACSLOADPATH for the login shell environment, via .bashrc, .profile, and system wide via /etc/profile, I have not been able to have '/usr/bin/emacs23' have EMACSLOADPATH set when invoked via the LXDE UI. Thus, it would appear that emacs is not being initialized with the same environment that any of the shells are (old school?). Thus, what is it that one must update in order to have GNU emacs initialized with the same environment variables as bash? Or, put another way, why aren't the environment variable defined in /etc/profile, ~/.bashrc and/or ~/.profile ending up in the initialized environment upon invocation of emacs23 on lubuntu Linux?

Emacs Message:
Warning (initialization): An error occurred while loading `/home/odoncaoa/.emacs':

-->> Not set in environ: EMACSLOADPATH

.emacs code:
;; ============================
(if (eq (getenv "EMACSLOADPATH") nil) (error "\n-->> Not set in environ: %s\n" "EMACSLOADPATH") (message "EMACSLOADPATH\t\t=\t%s\n" (getenv "EMACSLOADPATH")) )
Old 08-07-2010, 06:24 PM   #2
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Try putting them in /etc/environment. It's the file used for loading system-wide environmental variables.

bashrc is usually only loaded when an interactive shell is started, so you don't generally get them at startup. And of course the personal $HOME versions don't load unless you're logged in as that user.

Also, the shell that the OS uses internally for running startup scripts may not be bash. My debian system is set to use dash, for example.

I'm not sure about /etc/profile though. I think it depends on how the distro's startup scripts are configured. I wonder if you could source it into /etc/environment? Or if it's wise to do so if possible.

Edit: To answer my own questions, it seems that when you do a graphical login, your login manager won't read /etc/profile unless specifically set up to do so. Also, /etc/environment can only contain simple key=value pairs, so no, you can't source anything else into it. This mailing list thread helped me to comprehend it:

Last edited by David the H.; 08-07-2010 at 06:34 PM. Reason: as explained
1 members found this post helpful.
Old 08-07-2010, 07:35 PM   #3
LQ Newbie
Registered: Aug 2010
Posts: 4

Original Poster
Rep: Reputation: 0
David the H., thanks so much. I had tracked down /etc/environment and tried that as well. I hadn't quite remembered it in the list that I specified in the post, however. Consequently, inclusion into /etc/environment didn't do didly for me, either? However, you gave me some leads to investigate, so thanks again!

As lubuntu is a relatively newly generated, I am begining to suspect that this little tidbit is, in fact, a booboo.
Old 08-16-2010, 08:06 AM   #4
LQ Newbie
Registered: Aug 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Exclamation Re: initialized environments for shells vs. emacs?


Sorry for the delay, and the delay on the socially immersive systems coordination. Anyway, while more light has been shed upon the issue, it has taken a bit of time. I have been able to verify that the environment variables that are initialized, and present in bash, also exist within emacs, I have not been able bring an initialized 'EMACSLOADPATH' into emacs. The final test I had was to see if this was true for any/all of the rest of this users exported (or not) environment variables (as 'EMACSLOADPATH' holds special significance within emacs).


bash, cygwin, emacs, environment, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can all shells read all environmental variables set by other shells? carlodelmundo Linux - Newbie 2 07-23-2010 02:03 PM
emacs: running multiple M-x shells? genmaicha Linux - Software 2 04-17-2009 12:41 PM
emacs prompt in shells (esp. py-shell) CoonerTheRed Linux - Software 0 05-08-2006 10:45 AM
Linux shells testament Linux - General 1 07-02-2004 11:07 PM
linux booting problem with non-initialized swap space the_twister Linux - General 1 09-04-2003 12:11 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration