How to access a bash environment variable from within R in emacs-ess

≡放荡痞女 提交于 2019-12-04 04:46:43

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")))

the .bashrc might not be read when the xsession is started. Try adding

export SETTINGS=/home/user/settings.xml

in the .xsessionrc or the .gnomerc (if you are using gnome). Those file are loaded at startup for the X session.

If you start you an R session inside emacs, then the R session will have the same environment variables as emacs. So you should first make sure that you start emacs in such a way that its environment contains your SETTINGS variable. That way, your R session, which you start inside emacs, will have SETTINGS also in its environment. How exactly to achieve this depends on your system.

Jason Morgan

You can put

SETTINGS <- "/home/user/settings.xml"

in .Rprofile as a work-around.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!