8

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!

Community
  • 1
  • 1
Berk U.
  • 7,018
  • 6
  • 44
  • 69

2 Answers2

17

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.

Jonathan
  • 8,497
  • 41
  • 35
  • So the first solution does not work for me... However, the second solution does. Thank you so much! – Berk U. Oct 21 '14 at 17:35
  • 2
    `open -a rstudio` is somewhat simpler, and most probably does the same (cannot try, don't have 10.10). – Gabor Csardi Oct 22 '14 at 19:46
  • 3
    Just an update for folks who are hitting this: we now fully understand the issue and we'll have a fix in RStudio soon. – Joe Cheng Oct 27 '14 at 23:02
  • @JoeCheng Is this considered fully resolved? I'm still having the ```texi2dvi``` error when using a task scheduler to run a .Rnw file: http://stackoverflow.com/questions/41731493/texi2dvi-error-when-running-a-rnw-script-with-launchcontrol – Nancy Feb 07 '17 at 19:56
0

There are a host of questions about similar problems. All of them appear to come up when you update OS X to either Yosemite or Sierra with an older version of R already installed.

The easiest solution is to completely uninstall R (note the comments about using which R !), and then to install it again.

This also solves problems such as R showing different version numbers in terminal and the GUI.