I've recently updated to R 4.0.2 and am having horrific issues with devtools installation. I am getting the following error:
# approach 1
install.packages("devtools")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.0/devtools_2.3.2.tgz'
Content type 'application/x-gzip' length 337605 bytes (329 KB)
==================================================
downloaded 329 KB
library(devtools)
Error: package or namespace load failed for ‘devtools’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/9/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so
Reason: image not found
# approach 2
install.packages("devtools", type = "source")
trying URL 'https://cran.rstudio.com/src/contrib/devtools_2.3.2.tar.gz'
Content type 'application/x-gzip' length 373387 bytes (364 KB)
==================================================
downloaded 364 KB
* installing *source* package ‘devtools’ ...
** package ‘devtools’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/9/libgomp.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/pkgload/libs/pkgload.so
Reason: image not found
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘devtools’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/devtools’
Warning in install.packages :
installation of package ‘devtools’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/_5/rq2_d4m14rj0c2vsh_8mbhgh0000gn/T/Rtmp3x5lzg/downloaded_packages’
This makes sense: I actually have gcc10 instead of gcc9, installed via homebrew:
ls /usr/local/opt/gcc/lib/gcc/
drwxr-xr-x 47 darya staff 1504 19 Aug 13:18 10
I am not sure why R is not seeing that more recent version of gcc? Moreover, astoundingly, Rcpp works (and I've tested it with the basic code in the documentation vignette, so it not only loads, but also actually works).
is the Makefile signifying that it was expecting to find version 9. Version 10 won't do. It is possible, of course, to edit the Makefile, but probably not how most users should be spending time.
Hi Darya,
It looks like the pkgload package isn't pointing to your current gcc installation.
To answer your other questions first, I think that without a ~/.R/Makevars file, R will default to the clang identified by typing "which clang" in the terminal (Default compilation settings for R are in
/Library/Frameworks/R.framework/Versions/4.0/Resources/etc/Makeconf). This is probably why R isn't picking up your current installation of gcc10.
The easiest way to fix it is to re-install "pkgload" as a binary as it is a
dependency of devtools, and then re-installing devtools.
The longer way is to first create or update your ~/.R/Makevars file to use gcc-10 from homebrew, and then reinstalling pkgload and devtools from source.
An example of my Makevars file is below.
@jrmuirhead can weigh in on the advantages of making a major intellectual capital and time investment in optimizing a macOS toolchain. I'll address the disadvantage
As a user of R, it's time better spent using R.
Members of the R Core Development Team, notably Simon Urbanek, devote considerable time to compiling macOS binaries from R package source code. Oftentimes, little is involved, because the dependencies are simple and the source code will compile for any user with a reasonably current set of the XCode CLI tools. Other times, however, it takes someone who is probably on a first-name basis with the Gods of Unix to figure out. In between are mere mortals who struggle getting it right.
On other Unix flavors, such as the Debians, compilation seldom fails for any reason other than a missing system library, which is easy to fix. That's because source packages aren't released if they don't compile in Linux.
This intro gives a flavor of makefiles at their simplest. Production code is often hundreds of lines long.