Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running system command from R console cannot locate installed programs since upgrading to Mac OSX 10.10

Tags:

macos

r

rstudio

I have been having some weird issues with R (3.1.1) and RStudio (0.98.1079) and I suspect that it is due to the fact that these programs are not longer referencing the right places after I upgraded to Mac OSX 10.10.

In particular, I cannot seem to find packages that I know I have installed on my computer to run using the system command in the R console. That is, running man pdflatex in a Terminal window yields the help manual for PDFLATEX. However running system('man pdflatex') from the R console yields the error message No manual entry for pdflatex.

The issue persists even though I reinstalled R, RStudio and MacTex since I upgraded to Mac OSX 10.10. Any help would be appreciated!

like image 516
Berk U. Avatar asked Oct 21 '14 16:10

Berk U.


People also ask

How do you run an R command on a Mac?

In the Script Editor app on your Mac, click the Run button in the toolbar, or press Command-R, to execute the commands in your script.

Where are R packages installed Mac?

The home location for R packages from the Mac finder on my machine is "desktop/Macintosh HD/Library/Frameworks/R. framework/Resources/library/". Within library you will see all the packages that you have downloaded, and installed.


1 Answers

Yosemite has a bug wherein some environment variables, including PATH, appear twice in a program's environment with different values. For instance, you might notice that Sys.getenv("PATH") will show you one PATH, and system("echo $PATH") will show you an entirely different one.

I expect that most of your problems are due to this bug.

There are a few workarounds you can try immediately:

  1. You can manually forward PATH yourself. Try this:

    > system2("man", "pdflatex", env=paste0("PATH=", Sys.getenv("PATH")))
    
  2. Or, you can start RStudio from Terminal:

    $ open /Applications/RStudio.app
    

Both the R and RStudio engineers have implemented workarounds in the last few days. R (as of 3.1.2) and RStudio (as of 0.98.1087) should behave as you'd expect.

like image 189
Jonathan Avatar answered Oct 02 '22 18:10

Jonathan