简体   繁体   中英

Emacs on Mac, R, and OS X el Capitan

I use Emacs and/or Aquamacs on a Mac system to edit the R, latex, and html code. After upgrading OS X to el Capitan, R stopped working (searching for program: no such file or directory, R). I was wondering if anybody encountered the same problem and found the solution.

This is what I did and it solved the problem.

  1. re-install R (the latest version at the time of writing this post is 3.2.4)
  2. include (setq exec-path (cons "/usr/local/bin" exec-path)) in the .emacs. /usr/local/bin is where the command line R is soft linked.

Of course if the R command is not found in /usr/local/bin but somewhere else, you should change the path in step 2.

I had to re-install R and all the packages after upgrading. To be able to do this step easily, save your installed packages in a file before upgrading to El Capitan. The packages have not actually been removed, they reside in /Library/Frameworks/R.Framework/Versions/3.2/Resources/library (3.2 = version), so you can still find them, but some may be in your user library.

To save your list of packages:

my.packages = library()[[2]] write.table(my.packages,file="my.packages.txt", row.names=F, col.names = T)

Then upgrade, re-install from R-3.2.2.pkg (or latest), then read the text file in my.packages and use install.packages(my.packages, repos=' http://cran.us.r-project.org ') and you should be good to go.

Regarding R under "El Capitan", you do not necessarily have to re-install it. You can find out what happened by listing the directory

ls -l /Library/SystemMigration/History/Migration-<UUID>/QuarantineRoot/usr/bin

(where <uuid> looks like 38CF2251-9593-48E9-BAA4-4880AA47E908 ). This is where the OS upgrade put the links that used to live in /usr/bin . Just create the same symlinks to R and Rscript as root:

cd /usr/local/bin
ln -s /Library/Frameworks/R.framework/Resources/bin/R R
ln -s /Library/Frameworks/R.framework/Resources/bin/Rscript Rscript

This assumes, of course, that /usr/local/bin is in your PATH .

New installations of R should be aware of the changes in El Capitan, cf. this R bug report .

Here is another solution: replace emacs with ``modified emacs''. It solves all the problems with Auctex (latex-preview-pane-mode) and R. It is also consistent with OS 10.11.

You can download it from: http://vgoulet.act.ulaval.ca/en/emacs/mac/

I had the same problem getting R to run on El Capitan. The problem is now solved. What follows is exacly what I tried. You might find some of the steps irrelevant but I've included them for the sake of completeness.

  1. Tried reinstalling it via homebrew (mentioined above) and got an incompatible message concerning el capitan.
  2. Loaded 'modified emacs' (mentioned above).
  3. Visited the following link: http://ftp.heanet.ie/mirrors/cran.r-project.org/bin/macosx/

then downloaded and installed: (i) R-3.2.2.pkg and ran the checksum command in Terminal as directed by the instructions. (ii) XQuartz 4. Then in terminal, typed R and it worked.

  1. For the course I'm doing, other packages or libraries were needed. To load the package 'geonames, in Terminal type: install.packages(c("geonames"))

    A message will appear asking to select a CRAN mirror. Also another window will open with a list of mirrors, click one and OK.

Similarly, the package 'UsingR' was loaded by: install.packages(c("UsingR"))

__end

I think the problem is that usr/bin is no longer writeable. And that's where programs like R and Rscript lived. On my system, it looks like usr/bin was moved to something like:

/Library/SystemMigration/History/Migration-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/QuarantineRoot/usr/bin

I suppose you can add that quarantined folder to your path as on my system everything seems to be working fine if executed from there.

I had the same problem. I'm not sure what's changed in El Capitan but adding the path to the R binary ( /usr/local/bin on my system) to the exec-path in my .emacs file fixed the issue for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM