Every libraries failed to load after upgrading R to 3.6.0

I needed to install the R package quadprog, which only works for R with version 3.6.0. So I installed R (3.6.0 version), and open it with RStudio. But now I failed to load any libraries, even after I installed the packages successfully using install.packages("package_name"). Specifically, the libraries I need to load are caret, forecast and ggplot2. I tried re-installing R but it still does not work. The error message I get is

Error: package or namespace load failed for ‘forecast’ in
dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so,
6): Symbol not found: ___cxa_uncaught_exceptions Referenced from:
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib
Expected in: /usr/lib/libc++abi.dylib in
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib

After installing Rcpp package successfully with install.packages("Rcpp") , I still got the message above when I tried library(Rcpp). So I am completely stumbled here...(before upgrades, everything works fine except I cannot install quadprog, so cannot install forecast package as well). Can anyone please help me fix this issue?

Please see below the images showing that the packages are stored in the same directory path of the R.

After updating to R 3.6.0, have you updated your packages with checkBuilt=TRUE?

update.packages(repos='http://cran.rstudio.com/', ask=FALSE, checkBuilt=TRUE)
2 Likes

I just tried it, but still got the same error message (please see the image). By the way, I used Mac OS X El Capitan (10.11.2).

I looked it up based on your suggestion, and what i found weird is that it does contain .dylib bu and Rcpp.so (see the image below for Rcpp.so). The other files, I just copied them from another folder named libraries" in the same directory path 3.6 -> Resources.Why do we havelibandlibraries` though?

On the other note about compiling from source: I did choose that option by accident, but do you know how I can specify that within install.packages("caret")?

Another image shows the file libc++.1.dylib in the correct place. Really confusing why it still fails...

I tried loading ggplot2, and got this

Try restarting your R session (Ctrl+Shift+F10), reinstalling Rcpp install.packages("Rcpp") and then try to load ggplot2 again. Do you get the same error message?

1 Like

I tried it, and still got the same problem.

I also checked and found that the Rcpp folder was located in the same directory path as shown in .libPaths() above.

I tried loading a random library, like library(lattice), and it works! But ggplot2 still does not work, and i am puzzled...

Do you get any additional error message if you reinstall ggplot2?

install.packages("ggplot2", dependencies = TRUE) 
1 Like

I tried it too, and still got the same error message as above. Note that I tried loading library(stats) and library(lattice), they worked well. Not library(tidyverse) unfortunately, so cannot include the Rcpp.

Be sure that you have the latest version of XCode and install the command line utilities (xcode-select --install).

The library is lib (singular) and it should have

 $ 521:  ls -l
total 21352
-rwxrwxr-x  1 root  admin   3.5M Apr 26 09:42 libR.dylib*
drwxrwxr-x  3 root  admin    96B Apr 26 09:41 libR.dylib.dSYM/
-rwxrwxr-x  1 root  admin   185K Apr 26 09:42 libRblas.0.dylib*
lrwxr-xr-x  1 root  admin    16B Apr 26 17:59 libRblas.dylib@ -> libRblas.0.dylib
drwxrwxr-x  3 root  admin    96B Apr 26 09:41 libRblas.dylib.dSYM/
-rwxrwxr-x  1 root  admin   2.1M Apr 26 09:42 libRlapack.dylib*
drwxrwxr-x  3 root  admin    96B Apr 26 09:41 libRlapack.dylib.dSYM/
-rwxrwxr-x  1 root  admin   825K Apr 26 09:42 libc++.1.dylib*
-rwxrwxr-x  1 root  admin   212K Apr 26 09:42 libc++abi.1.dylib*
-rwxrwxr-x  1 root  admin   271K Apr 26 09:42 libgcc_s.1.dylib*
-rwxrwxr-x  1 root  admin   1.5M Apr 26 09:42 libgfortran.3.dylib*
-rwxrwxr-x  1 root  admin   571K Apr 26 09:42 libomp.dylib*
-rwxrwxr-x  1 root  admin   278K Apr 26 09:42 libquadmath.0.dylib*
-rwxrwxr-x  1 root  admin   973K Apr 26 09:42 libreadline.5.2.dylib*
lrwxr-xr-x  1 root  admin    21B Apr 26 17:59 libreadline.dylib@ -> libreadline.5.2.dylib
-rwxrwxr-x  1 root  admin    65K Apr 26 09:42 libunwind.1.dylib*

It's for system wide R use.

All the packages live in library

The first error message was complaining about

/library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs

which should have

 $ 528:  ls -
total 1112
-rwxr-xr-x  1 rc  admin   555K Apr 26 12:52 Rcpp.so*
drwxr-xr-x  3 rc  admin    96B Apr 26 12:52 Rcpp.so.dSYM/

When you run `update.packages("some_package") and you see

> update.packages()
RcppArmadillo :
 Version 0.9.300.2.0 installed in /Library/Frameworks/R.framework/Versions/3.6/Resources/library 
 Version 0.9.400.2.0 available at https://ftp.osuosl.org/pub/cran
Update? (Yes/no/cancel) y

  There is a binary version available but the source version is later:
                   binary      source needs_compilation
RcppArmadillo 0.9.300.2.0 0.9.400.2.0              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘RcppArmadillo’

there's about a 50% chance it will compile successfully. If you're not asked, that means you're getting a binary and you should have no problems.

Trying to fix these things manually by moving around files is a sure recipe for disaster. It will take a couple of hours, but what I'd do is 1) upgrade to Mojave, 2) install XCode, 3) install the XCode cli, 4) re-install the Mac binary from CRAN, 5) take @andresrcs' suggestion

1 Like

I checked my xcode with your suggested cmd, and it gave me the message that No update is available. So looks like everything is up to date.

Thank you so much for your help. I tried out the lib(singular) but got the error message shown in the figure. The update.packages() worked for me (see the same figure). I am not quite sure what you mean with "upgrading to Mojave," and "reinstall the Mac binary from CRAN," so can you please be more explicit?
34%20PM

You have XCode version 10.2.1? (I'm guessing you might not if you're still on High Sierra)

I just check. My Xcode version is 7.3.1, but I cannot see how to update it (the update from Appstore takes forever for Xcode to run, and it also disappeared from the list of items that need to be updated already).

It doesn't need to be updated to run High Sierra, it needs to be updated to run Mojave. My advice is to totally avoid trying to compile any packages if they don't work the first time.

So I still don't know what is the actual problem that causes R's version 3.6.0 failed. Trying to ask my friend who was able to install forecast package with R 3.4 (?!) I now had to downgrade R to 3.5.2 in order to be able to use other libraries.

Try

install.packages("Rcpp", type = "source")

and rerun

3 Likes

I tried it previously, and still got the same error message when trying to load library(forecast) or library(caret)

If you've recently updated your R version, it will look for your installed libraries in a new directory, e.g., R/x86_pc_linux-gnu-library/3.6 (where previously you used, e.g., R version 3.4). On Windows platforms, there is a hand function to move all your installed libraries over to the new directory. For MacOS and Linux platforms, many libraries need to be compiled from source. I haven't yet found something similar.

However, I did find a hand post by a fellow R user that does the trick:

# update_R_packaged.R
# change the next line to reflext your "old" R library location on your disk
lib_loc <- "/home/<your_home dir_name>/R/x86_64-pc-linux-gnu-library/3.4"
old_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])
currently_installed <- installed.packages()
to_install <- setdiff(old_install, currently_installed)
install.packages(pkgs = to_install)

This takes a while but is more robust compared to just copying over all the sub-directory folders from your old R version to the new R version. This may not be the solution to the problem you face, but it sure seems like there are just multiple unresolved library dependencies that are causing the issue.

--d