How can I specify the R version opened by ESS sess

2019-05-16 12:52发布

问题:

This question already has an answer here:

  • ESS to call different installations of R 2 answers

When I want to open an R session in emacs, I use M-x R.

However, our server has both R 2.12 in /usr/bin/R and R 2.15 in /usr/local/bin/R. Actually, if I ask whereis R, I get the following:

$ whereis R
R: /usr/bin/R /usr/local/bin/R /usr/local/bin/R2.15 /usr/local/bin/R2.12 
/usr/local/bin/R2.7 /usr/include/R /usr/share/R /usr/share/man/man1/R.1.gz

When I try to export "R_HOME=/usr/local/bin/R2.15" from .bashrc, emacs says "WARNING: ignoring environment value of R_HOME"

Is there a way to choose which instance of R is launched? Currently, 2.15 is launched when I type R at the command line, even though M-x R launches 2.12.

回答1:

The non-ESS answer is to make sure your PATH is identical, and the version you want comes first. There appears to be difference between the shell you launch, and the launch involving Emacs. You could launch Emacs from your shell with its PATH.

The ESS answer probably involves setting some magic variable... On Windows we often set the binary directly. Here the lisp code says:

;; If you wish to call other versions of R on a Unix system, ESS
;; should auto-detect other versions of R, according to matches to the
;; variable `ess-r-versions' as described in its docstring.  Consider
;; changing that variable rather than changing inferior-R-program-name
;; if your version of R is not already auto-detected.
;;(setq-default inferior-R-program-name "R")        ; unix systems

so it should just work. I keep only R in my PATH, and another out of it so I can't test this here for you. But try fiddling with ess-r-version and/or inferior-R-program-name.