I have the following in my .bashrc

export R_LIBS_USER="/home/wdkrnls/R/lib/3.2"

When I start R from the shell I see (even in Emacs M-x shell):

[1] "/home/wdkrnls/R/lib/3.2"  "/usr/lib/R/library"

When I start an R process with M-x R, I see:

[1] "/usr/lib/R/library"

How do I make ESS know about and use official R environment variables instead of ignoring them?

  • 2
    You'd also need to add (setenv "R_LIBS_USER" "/home/wdkrnls/R/lib/3.2") to your Emacs init file. In general, this is related to how environment variables are inherited by programs. Most likely you are running Emacs from shell that does not read that .bashrc. There are also Emacs packages that parse environment variables from shell started from current user account and add them to Emacs environment, but I cannot remember the name at the moment.
    – wvxvw
    Jan 3, 2016 at 21:25

1 Answer 1


Following, @wvxvw's comment: I was starting Emacs from an environment which wasn't executing my .bashrc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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