I recently "upgraded" from OSX Mountain Lion to Yosemite and from R 3.1.3 to 3.2. Immediately after the upgrade, when I opened R or RStudio I got a pop-up message saying that I needed to install Java 6. In addition, loading rJava or any package that depends on rJava (e.g., xlsx) caused RStudio to crash (R also crashed when I tried this by opening R.app directly).
After trying a few fixes found on Stack Overflow and elsewhere (more details below), I am at a point where loading rJava or any package that depends on rJava no longer causes R to crash, but results in the following error:
library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package or namespace load failed for ‘rJava’
However, if I invoke R from the command line and then load rJava or any package that depends on rJava, it seems to work (or at least I don't get any error messages).
I've tried a number of different attempted fixes, some of them a few times, and can't quite remember exactly what I did in what order (didn't realize this would be such a morass and wasn't really keeping track), but here's the gist of it:
Added the following to my .bash_profile (per this SO answer):
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/server
Reconfigured java from the command line as follows:
sudo R CMD javareconf -n
Checked options("java.home") and discovered this was set to NULL. I tried setting it to the following (per this SO question):
options("java.home"="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre")
Installed the latest Java Development Kit and reinstalled rJava from source (can't remember where I found that one).
At some point while trying all of these, I was able to load rJava without crashing R, but instead got the error message posted above. In addition, when I quit RStudio, it would seem to close normally, but then an "RStudio quit unexpectedly" message would pop up, indicating that the program had crashed while trying to close.
I finally decided to install Java for OS X 2014-001 (Java 6), as I seemed to be running out of options. Now, when I opened R or RStudio the "This software needs Java 6" pop-up message no longer appeared. However, I was still getting the .onLoad failed in loadNamespace() for 'rJava' error message posted above.
In reviewing some of the posts I'd already looked at, I noticed another SO answer that I'd missed before, which recommended opening RStudio with the following command line code that gives RStudio the correct path to java:
LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio
That opened an RStudio window and I was also able to load rJava and packages that depend on it without getting an error.
Lastly, I tried running R from the command line (which I hadn't done before). It turns out that on the command line, loading rJava or any package that depends on rJava works and does not throw any errors.
So, I can now get rJava to work if I open RStudio from the command line with the code that gives RStudio the java path (as noted above). However, I'd like to find a way to fix the underlying problem, whatever it may be, so that RStudio can be opened in the usual Mac way, without needing a command line kludge. I'm also concerned that having an old version of Java installed could cause problems down the road.
Does anyone have any ideas about how to diagnose and solve this issue?
I had the same problem and went through the same steps as you. The final step to allow starting RStudio through Finder/Spotlight was to link libjvm.dylib to /usr/local/lib:
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
-f flag is added to force overwriting existing file/link
On OSX El Capitan 10.11, the user doesn't have permission to write to /usr/lib. So instead, use the following command:
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
You can load the libjvm.dylib explictly, by run like
dyn.load('/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/server/libjvm.dylib')
library(rJava)
On macOS High Sierra (10.13.1) and Java Version 9 you have to use a slightly different JVM path (notice the missing jre folder in the path compared to the instructions for earlier Java versions):
sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib
You also have to notify R about the JVM:
MY_R_VERSION=$(Rscript -e "cat(with(R.version, sprintf('%s.%s', major, substring(minor, 1, 1))))")
ln -s /usr/local/lib/libjvm.dylib /Library/Frameworks/R.framework/Versions/$MY_R_VERSION/Resources/lib/
Following command works:
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
After that, in RStudio, loading rJava works through loading of the "xlsx" package.
library("xlsx")
P.S. #1 Environment: Mac OS X El Capitan 10.11.3+ with RStudio 0.99.491+ and R 3.2.3+. (I've now tested this also on macOS Sierra (10.12) and R.3.3.1.)
P.S. #2 I find that openxlsx is much faster and doesn't rely on Java to work, so I'm now using that package. Hope that helps others.
You should be able to use the CRAN rJava, without needing to recompile rJava or do any additional steps by linking the shared library to the R frameworks library directory.
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Libraries
This is how I configured it working properly on two Macs running Mac OS X El Capitan (10.11.6):
Uninstall 'rJava' by issuing the following commands in a terminal window:
Rscript -e 'remove.packages("rJava")'
sudo Rscript -e 'remove.packages("rJava")'
Download and install the Java software from Oracle: https://www.java.com/en/download/mac_download.jsp
Add the following lines to /Users/<userid>/.bashrc using your favorite editor:
# Set JAVA_HOME so rJava package can find it
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)/jre
Close and restart any terminal, R, and RStudio windows (to pick up the changes to .bashrc).
Run the following command in a Terminal window:
sudo ln -sf $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
Run the following command in a Terminal window:
sudo Rscript -e 'install.packages("rJava", repos="http://rforge.net", type="source")'
Here is the easy steps for it:
remove the rJava package: remove.packages(rJava)
close R
install latest Java on you mac
open terminal and type this command: sudo R CMD javareconf
Open R and install rJava with this command:
install.packages("rJava", dependencies=TRUE, type="source")
The image not found issue exists with a brand-new install on OSX High Sierra with the latest Java SE 10 JDK.
I was able to solve the path issue with rJava using the fix found on the rJava Github issues page: https://github.com/s-u/rJava/issues/78
R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
Here what worked for me on MAC:
in your ~/.profile or ~/.bashrc add this line:
%export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
1.1 % source .profile (or % source .bashrc)
% sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
remove.packages(rJava)
remove.packages(Rweka)
From the terminal enter this command:
%sudo R CMD javareconf
install.packages("rJava", dependencies = TRUE, type = "source")
install.packages("rJava", dependencies = TRUE, type = "source")
Load your library("rJava", "RWeka")
Best of luck.
Maybe another simple answer which does not touch your filesystem:
$ install_name_tool -add_rpath /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/server /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
(Substitute jdk1.8.0_131.jdk with your JDK path.)
Check the location of libjvm.dylib file.
Try this, in my case this worked:
dyn.load('/Library/Java/JavaVirtualMachines/jdk-10.jdk/Contents/Home/lib/server/libjvm.dylib')
library(rJava)
I went through all the troubleshooting I could find, then installed jdk-11.0.1_osx-x64_bin.dmg from: Oracle downloads
Everything worked perfectly after that.
Check the version of the library that was not loaded when you run library('rJava') and match it to the java version you need installed.
I noticed that 'rJava' is pretty strict about JDK version while loading in Rstudio. In my case (Mac OS. 10.14.6 - Mojave) I had installed jdk-13 which was tested against jdk-11.
I have linked my JDK version to a non-existent directory that was assumed to be valid by Rstudio (JDK 11):
sudo ln -sf /Library/Java/JavaVirtualMachines/jdk-13.jdk/ /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk
and suprisingly it works like a charm...
BTW., there was no problem to run 'rJava' following the previous instructions in native R.
Here you can download the legacy Java version 6 for El Capitan: https://support.apple.com/kb/DL1572?viewlocale=en_US&locale=en_US
After doing so, the rJava package works for me.
This line below has solved the same problem I was having with rJava package as some others in this discussion did. I'm sure there are more than one solution to this problem and I sincerely thank them all for their contributions because sometimes one line like the one below saves a lot of time from going to trash!
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
Run the following on the command line: sudo R CMD javareconf
Several solutions above have mentioned this, but they also suggest that one remove and subsequently re-install the rJava package. I found those additional steps to be unnecessary.
You can change the reference in R by using the following command:
sudo install_name_tool -change /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so
Related
I have a general question about how to effectively load any kind of external package into R. I have found that many sources detailing this information are simply insufficient, but I will leave out mentioning those respective URLs. I have successfully loaded external packages into R before, but I am having difficulties loading the fgui package.
In my specific case, I cannot load the library fgui into R Studio. First I download directly from CRAN with the command:
install.packages("fgui", lib="~/Documents/R_dir")
This works fine for me. My working directory is set to ~/Documents/R_dir
The next command I use is:
library("fgui", lib.loc="~/Documents/R_dir")
The error I get is:
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so, 10): Library not loaded: /opt/X11/lib/libX11.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/tcltk/libs/tcltk.so
Reason: image not found
Error: package or namespace load failed for ‘fgui’
I have examined the thread "Error when trying to load library(ggplot2) in R" but it did not answer my question.
Please help me with any suggestions to get the package fgui to work properly in R Studio and feel free to address the more general issue of effectively loading external packages into R.
tcltk is not a typical package. It's probably already installed on your system and it cannot be installed using the usual install.packages procedure because it is not on CRAN (just like the base packages that come with R, like stats, etc.). Also, tcltk2 is not the same as tcltk; that is a package that expands upon (and depends on) the functionality of tcltk.
So, start with this:
> capabilities("tcltk")
tcltk
TRUE
If that comes back FALSE it means that your R was not built with tcltk support. You don't say what OS you're using, so it's a little bit difficult to help you.
That said, if you're on Linux, you need to rebuild R with tcltk support. This should be relatively straightforward. Basically, make sure Tcl and tk are available on your system in a standard location (something like sudo apt-get install tcl8.5-dev tk8.5-dev) and then rebuild R per usual procedures.
If you're on Mac OS, you're encountering the same error that John Fox describes here in relation to Rcmdr. In short, it's probably one of two things:
A file permission issue related to the directory where you have Tcl installed. To quote Fox: "You can verify the source of this problem by issuing the following command at the R command prompt:
system("ls -ld /usr/local /usr/local/lib /usr/local/lib/libtcl*")
# ls: /usr/local/lib: Permission denied
# ls: /usr/local/lib/libtcl*: Permission denied
# drwx------ 8 root wheel 272 Sep 24 10:21 /usr/local
If the output of the system command looks like the above, you should go to Terminal and do the following: sudo chmod -R a+rX /usr/local and enter your password to change directory permissions.
You have an out-dated version of X-Windows. Try running Mac OS Software Update.
It may also be solvable by creating a symbolic link as described in this answer.
This should never come up on Windows, unless you built R from source without tcl/tk support.
On Arch Linux, tk is a separate package from tcl and both need to be installed:
sudo pacman -S tcl tk
This is given that the output from capabilities("tcltk") with R is TRUE (which means your R is compiled with tcltk support as noted previously in the answers here, this should be the case if you installed it from the arch repos).
The official installation instructions for R say:
Note: the use of X11 (including tcltk) requires XQuartz to be
installed since it is no longer part of OS X. Always re-install
XQuartz when upgrading your OS X to a new major version.
So: Simply (re)install XQuartz if you want to use the tcltk package in R.
delete the X11 file on location : /opt
delete the X11 on application unitiltiy
reinstall X11 again
Problem solved...
For Mac-OS users:
I struggled with this problem recently and found that R-3.1.2 has a bug, which assumes that otool is installed when it is not.
R-3.0.0 (and later) ships with Tck/Tk 8.6.0, so you shouldn't need to install that.
Simply upgrading to a more recent version of R (3.4.2) fixed the problem for me.
I had the same issue and went down a rabbit hole before discovering a simple fix. If you install R from bianry it will include tcltk by default. Just run the installer with the default installation. You can get the .dmg here: https://cran.r-project.org/bin/macosx/
Easiest answer for Mac users:
1- Install tcl-tk using brew:
brew install tcl-tk
2- Run the following code:
ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtcl8.6.dylib /usr/local/lib/libtcl8.6.dylib
ln -s /usr/local/Cellar/tcl-tk/$version/lib/libtk8.6.dylib /usr/local/lib/libtk8.6.dylib
Problem solved!
I've been using R and Rscript on my Linux CentOS 7 system and everything worked fine for years.
Today I tried to install a package, clusterSim, but my R environment does not seem to work anymore. Here's the error I get:
install.packages("clusterSim");
--- Please select a CRAN mirror for use in this session --- Warning: failed to download mirrors file (internet routines cannot be loaded);
using local file '/home/davide/miniconda3/lib/R/doc/CRAN_mirrors.csv'
Error: .onLoad failed in loadNamespace() for 'tcltk', details: call:
fun(libname, pkgname) error: Can't find a usable init.tcl in the
following directories:
/opt/anaconda1anaconda2anaconda3/lib/tcl8.5 ./lib/tcl8.5 ./lib/tcl8.5 ./library ./library ./tcl8.5.18/library
./tcl8.5.18/library
This probably means that Tcl wasn't installed properly.
I tried to install tcl, and I got this message:
sudo yum -y install tcl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile * base:
centos.mirror.rafal.ca * epel: mirror.math.princeton.edu * extras:
mirror2.evolution-host.com * ius: mirror.team-cymru.org *
nux-dextop: li.nux.ro * updates: centos.mirror.iweb.ca Package
1:tcl-8.5.13-8.el7.x86_64 already installed and latest version Nothing
to do
Any idea on how to solve this problem? Thanks
Something related to this is already reported as a bug but is closed off as partially corrected.
Have you tried this ?
install.packages("clusterSim", repos='http://cran.us.r-project.org')
Check out this for more !!!
Thanks to some friends on GitHub, I was able to solve this problem.
The problem is that now I have multiple versions of R on my laptop:
/usr/bin/R: the standard version I would like to use;
~/miniconda3/bin/R: the version installed by Miniconda that is causing me all the troubles.
First of all I had to understand what version is used by default by my system. I can do it with the which R command, that returned ~/miniconda3/bin/R
Then I realized I could have solve the problem by telling the system to stop using that R Miniconda version, and to employ the /usr/bin/R version instead.
I did this by editing the ~/.bashrc file. In the $PATH, my favourite R version path must be written before the Miniconda one.
Therefore my ~/.bashrc file now is something like this:
PATH=/usr/local/bin:$PATH
PATH=/usr/bin:$PATH
...
export PATH="$PATH:/home/davide/miniconda3/bin"
That's it; I hope this helps!
To me it looks like you are using R installed by conda. Do you also get this issue when you open R with /usr/bin/R in your terminal, because I believe which R will point to you conda repository.
See How to install R-packages not in the conda repositories? for extra info.
I solved this problem by using one of the following two approaches:
Prior to install a package I choose my CRAN mirror manually
chooseCRANmirror(graphics=F)
Prior to install I turn off the graphical menu
options("menu.graphics"=F)
Make sure conda in after /usr/bin in you PATH, check your ~/.bashrc
On ubuntu 14.04 with texlive, checking an R package, for example with devtools check() would return :
LaTeX errors found:
! LaTeX Error: File `inconsolata.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
! Emergency stop.
<read *>
l.276 ^^M
! ==> Fatal error occurred, no output PDF file produced!
Installing texlive-fonts-extra should take care of it.
You can also (though probably not recommented) tell Rd not to use inconsolata. Just change:
\DeclareOption{inconsolata}{\setboolean{Rd#use#inconsolata}{true}}
to
\DeclareOption{inconsolata}{\setboolean{Rd#use#inconsolata}{false}}
in your Rd.sty file. On my installation it is at :
/usr/share/R/share/texmf/tex/latex/Rd.sty
but a
locate Rd.sty
should find it on any system.
I'm on macOS using Homebrew and this worked for me:
# LaTeX tools like pdflatex
brew cask install basictex
# Install texlive packages needed to build R package vignettes
sudo tlmgr update --self
sudo tlmgr update --all
sudo tlmgr install titling framed inconsolata
sudo tlmgr install collection-fontsrecommended
If you are using the Travis Continuous Integration
service, your problem could be related to the CTAN
mirrors having yet to update.
The issue appears in the Travis R community forum:
might be related to the recent switch to TexLive-2019 as the LaTeX package manager seems to fail finding inconsolata in the repository.
...
It looks to me like the mirror chosen was has not updated to 2019, so I think this will resolve itself naturally when the mirrors catch up. If not I can look into it.
In the meantime, I solved it by forcing a previous version of TeXLive with a downgrade to OSX 10.12 in .travis.yml:
# macOS 10.12 version
osx_image: xcode9.2
See this Travis page for the correspondence between XCode and OSX versions and the original thread in DevOps StackExchange.
In Debian, instead of installing the huge texlive-fonts-extra package, run this at your shell:
tlmgr install inconsolata
updmap-user
I have Mac OSx and the accepted solution didn't work to me.
This was the solution in my case, to install mactex: https://tug.org/mactex/mactex-download.html
tlmgr gave me a warning about a checksum. However this worked
get inconsolata.tds.zip from https://ctan.org/pkg/inconsolata
cd /usr/share/texmf/
sudo unzip inconsolata.tds.zip
sudo mktexlsr
I have had this problem every time I upgrade R. I agree the 1.7GB texlive-fonts-extra is ridiculous for a small file, although I understand that it does give you a choice of several Klingon fonts
this is for texLive on Ubuntu
Hi I'm having issues with the rJava package from cran.
I have installed
sudo apt-get install openjdk-7-jdk
sudo apt-get install r-cran-rjava
and ran
sudo R CMD javareconf
# Java interpreter : /usr/bin/java
# Java version : 1.7.0_55
# Java home path : /usr/lib/jvm/java-7-openjdk-amd64/jre
# Java compiler : /usr/bin/javac
# Java headers gen.: /usr/bin/javah
# Java archive tool: /usr/bin/jar
I then try to run R and load rJava and get the following error:
R
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/lib/R/site-library/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘rJava’
I'm on Ubuntu 14.04 64 bit and am using R version 3.1.0 (2014-04-10) -- "Spring Dance"
UPDATE: Actually this is not specific to OpenJDK, I just tried oracle java 8 and got the same result. Also I found this workaround here which I am reluctant to use since it is indeed a workaround and doesn't really explain why it's necessary. The package system should have handled this in my opinion. Seems like libjvm.so is the problem and I have it located here
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server/libjvm.so
and for some reason rJava fails to find them despite updating with sudo R CMD javareconf.
UPDATE 2: The plot thickens: If I run R as sudo it works.
Thankful for pointers.
you can solve this problem by opening rstudio in super user like
sudo rstudio
then inside R run
install.packages('rJava')
I had the same problem with a similar configuration (R 3.1.0, Ubuntu 12.10, 32-bit). I found the answer was in getting LD_LIBRARY_PATH set properly, as described here:
error: unable to load installed packages just now except that the subdirectory in question is 'client' not 'server'. So now I'm setting my environment like this:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client
I was able to solve this permanentelly using this answer: https://stackoverflow.com/a/25932828/3939832
This is usefull if you have Oracle java 7 or 8 installed. Exporting variables in my case was not a permanent solution. You should check what R is using as environment by doing:
Sys.getenv("JAVA_HOME")
and then you can use that environment by creating a java.conf file on /etc/ld.so.conf.d/ as stated in the above answer link.
if you are using oracle java then use following command :
sudo R CMD javareconf
won't help use:
sudo R CMD javareconf **JAVA_HOME**=(path where java home is located)
I tried many things but didnt worked. Then I tried using
sudo rstudio
and then
install.packages('rJava')
Its working. Coool
Installing the rJava package on Ubuntu is not quite as simple as most other R packages. Some quick notes on how to do it(Source: https://www.r-bloggers.com/installing-rjava-on-ubuntu/).
Install the Java Runtime Environment (JRE).
sudo apt-get install -y default-jre
Install the Java Development Kit (JDK).
sudo apt-get install -y default-jdk
Update where R expects to find various Java files.
sudo R CMD javareconf
Install the package.
> install.packages("rJava")
If you have a RStudio session open, then exit and restart it. This is important (a running RStudio session will not pick up these changes!).
I am trying to plot using Rstudio. But when I do, plot(cars) which is the basic function, I am getting an Graphics Error in R.
Here is what I have done :
> plot(cars)
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
Please guide me through.
Solution for error:
Error in RStudioGD() :
Shadow graphics device error: r error 4 (R code execution error)
In R Studio, navigate to Tools, Global, Graphics (top middle), set Backend to AGG*, Apply, Ok
*Depending on your system/installation, you may have other other options in the drop down. Ex. AGG, Cairo, Cairo PNG.
AGG is a package which provides graphic devices for R based on the AGG library developed by the late Maxim Shemanarev. AGG provides both higher performance and higher quality than the standard raster devices provided by grDevices. You might need to install AGG. Compatible with R Studio since v1.4.
https://ragg.r-lib.org/
Initially, I reinstalled RStudio to the newest version (1.1.442) and, following many advice also the R-base* system (getting to R 3.4.3) using aptitude in the following way:
sudo aptitude reinstall libpangocairo-1.0-0 libpango-1.0-0
sudo aptitude reinstall r-base r-base-core r-base-dev
I used aptitude because it is usually better than apt-get to disentangle intricate dependency trees. Afterwards, when no package was loaded into the environment it was working just fine but any package loading was creating a whole variety of DLL-related errors as follows.
FINAL SOLUTION (NO NEED OF REINSTALL):
The error was showing again as soon as I loaded my self-made library. The real problem is the number of open DLL. If you load too many packages or files you will get to the limit and you will have error messages between maximal number of DLLs reached... or failed to load cairo DLL (this error warning) or even lapack routines cannot be loaded. I had these three error randomly as I loaded my full-of-dependencies-homemade-library.
So I started again looking for a solution. The final one is to allow more DLL and to do so it is enough to set the environmental variable R_MAX_NUM_DLLS to a higher number (I set it to 500). In order to avoid the hassle of setting it every time you can read ?Startup documentation and consequently write R_MAX_NUM_DLLS=500 in your Renviron file R-HOME/etc/Renviron.site. In my case (Ubuntu:16.04 it was /usr/lib/R/etc/Renviron.site. This fixed smoothly the problem.
Thank goodness, I just exited Rstudio and relaunched and the problem went away
Under Ubuntu 13.10
I had the similar issue with rstudio server, tried all different suggestions no work.
Finally figured out this way:
sudo service rstudio-server stop
remove all rstudio related files (sudo find / -name "rstudio" | xargs sudo rm -r)
uninstall R: sudo apt-get remove r-base-core r-base r-base-dev
remove all R related files (sudo find / -name "R" | xargs sudo rm -r)
re-install R: sudo apt-get install r-base-core r-base r-base-dev
test R: making sure plot(cars) works in R, output a pdf file.
re-install R studio server: http://www.rstudio.com/ide/download/server
I had the same issue and found James Mao's answer helpful, but I wanted to avoid reinstalling R so that I would not have to also reinstall all of my R packages. I was able to fix the issue by reinstalling RStudio without reinstalling R, which makes sense because the error is with RStudio, not R itself. Here are the instructions:
sudo service rstudio-server stop
remove all rstudio related files (sudo find / -name "rstudio" | xargs sudo rm -r)
re-install R studio server: http://www.rstudio.com/ide/download/server
Reinstall the package ggplot2 (install.packages"ggplot2") and invoke the library. It must work then
I meet this today, reindatall Rstudio still can't solve. finally installed textshaping
install.packages('textshaping'). It's ok now
I had the following error in a CentOS:7 Docker container when running rstudio-server verify-installation:
27 Feb 2017 14:17:09 [rsession-rstudio-server] ERROR r error 4 (R code execution error) [errormsg=Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) :
error in running command
]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::<unnamed>::evaluateExpressionsUnsafe(SEXPREC*, SEXPREC*, SEXPREC**, rstudio::r::sexp::Protect*, rstudio::r::exec::<unnamed>::EvalType) /root/rstudio/src/cpp/r/RExec.cpp:159; LOGGED FROM: rstudio::core::FilePath rstudio::session::module_context::findProgram(const std::string&) /root/rstudio/src/cpp/session/SessionModuleContext.cpp:879
27 Feb 2017 14:17:09 [rsession-rstudio-server] ERROR r error 4 (R code execution error) [errormsg=Error in system(paste(which, shQuote(names[i])), intern = TRUE, ignore.stderr = TRUE) :
error in running command
]; OCCURRED AT: rstudio::core::Error rstudio::r::exec::<unnamed>::evaluateExpressionsUnsafe(SEXPREC*, SEXPREC*, SEXPREC**, rstudio::r::sexp::Protect*, rstudio::r::exec::<unnamed>::EvalType) /root/rstudio/src/cpp/r/RExec.cpp:159; LOGGED FROM: rstudio::core::FilePath rstudio::session::module_context::findProgram(const std::string&) /root/rstudio/src/cpp/session/SessionModuleContext.cpp:879
I fixed it by installing which command: yum install which
I had the same error and am on Ubuntu. I did not install R through sudo apt-get install r-base but instead downloaded a specific version, unpacked it and installed it manually with:
./configure --with-readline=no --with-x=no --enable-R-shlib
make
sudo make install
I did not have cairograpghics installed, which is apparently important to build 2D graphics with R. So I installed that with:
sudo apt-get install libcairo2-dev
Or find the version for your OS here: https://www.cairographics.org/download/
I then uninstalled R again by simply going into the downloaded R folder that I had previously compiled using the above commands mentioned and typed:
sudo make uninstall
And then I configured and installed the same R version again. That did it. The uninstall and reinstall was important, just installing cairographics didnt work, you have to have it installed before using ./configure.
I had the same problem (even though I had been using the same installation for over a year without this problem).
I just needed to restart the computer and everything was good again.
:D