Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8075181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:54:18+00:00 2026-06-05T14:54:18+00:00

In my .bashrc, I have the line: export SETTINGS=/home/user/settings.xml If I load R in

  • 0

In my .bashrc, I have the line:

export SETTINGS=/home/user/settings.xml

If I load R in bash, I can access this variable using the Sys.getenv function:

Sys.getenv("SETTINGS")
"/home/user/settings.xml"

If I open up R in Emacs (M-x R), SETTINGS is empty:

Sys.getenv("SETTINGS")
""

What I have tried:

  1. adding the following to .emacs, based on How do I make Emacs recognize bash environment variables for compilation?

    ;; get environment vars from .bashrc
    (let ((path (shell-command-to-string ". ~/.bashrc; echo -n $SETTINGS")))
      (setenv "SETTINGS" path))
    
  2. opening up bash in emacs using M-x term

    echo $SETTINGS         # works
    R
    Sys.getenv("SETTINGS") #works
    
  3. If I open emacs from the terminal, the SETTINGS variable is available as expected. Opening emacs from the Applications menu (with either the command /usr/bin/emacs23 %F or emacs) does not work.

  4. comparing output from session("env") when loading R in bash vs emacs, but nothing stands out other than (bash = <, emacs = >):

    > INSIDE_EMACS=23.3.1,comint
    6d5
    < SETTINGS=/home/user/settings.xml
    9c8
    < SHLVL=1
    > SHLVL=0
    14a14
    > PAGER=cat
    16d15
    < PAGER=/usr/bin/pager
    19d17
    < COLORTERM=gnome-terminal
    25c23
    < WINDOWID=14680069
    > DESKTOP_AUTOSTART_ID=1020ce948b944a88113395253627645060000001863000
    < TERM=xterm
    > TERM=dumb
    

Can I either

  1. access SETTINGS from within R in emacs-ess
  2. export SETTINGS somewhere that I can access it?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:54:20+00:00Added an answer on June 5, 2026 at 2:54 pm

    I don’t know about R and self-defined environment variables, but I set the PATH variable in emacs to the same value as in my bashrc. I modified my code to your problem, give it a shot and let me know if it works.

    ;; set env variable in Emacs
    (getenv "SETTINGS")
    (setenv "SETTINGS" "/home/user/settings.xml")
    

    Original code (for PATH) is:

    ;; Emacs has its own path variable
    (getenv "PATH")
     (setenv "PATH"
    (concat
     "/usr/local/texlive/2011/bin/x86_64-linux" ":"
    (getenv "PATH")))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting PYTHONPATH set. I have added this line to ~/.bashrc
So currently I have included the following in my .bashrc file. export RUBYLIB=/home/git/project/app/helpers I
In my /etc/bash.bashrc file, I have following: export SYNCTOOL=/root/Desktop/gb alias synctest='python $SYNCTOOL/App.py' In App.py:
I have this self-defined function in my .bashrc : function ord() { printf '%d'
I have two recipes: Configures my home directory with things like my .bashrc, run
My .bashrc looks something like this... export PERL5LIB=/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0/${PLAT}-thread-multi export PERL5LIB=${PERL5LIB}:/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0 function dev { export
Hi I have added this alias to my .bashrc: alias awrco='svn co https://x.x.com/x/x/x/projects/' I
In my .bashrc file I have included the following: GIT_PS1_SHOWDIRTYSTATE=true GIT_PS1_SHOWUNTRACKEDFILES=true GIT_PS1_SHOWUPSTREAM=verbose git export
Please help me understand this. Here you can see that I have PYTHONPATH set
I'm a pretty active command line user and I have shell accounts all over

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.