renv can't install package from source

I'm starting a new project using renv. I have initialized the project, and have begun installing projects. I can install binary package files into my renv project without issue, but compiling with source fails, despite succeeding outside of any renv project. For example: renv::install("data.table", type = "source") (or install.packages("data.table", type = "source")) yields:

Retrieving '' ...
	OK [file is up to date]
Installing data.table [1.14.2] ...
Error installing package 'data.table':

* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** using staged installation
*** pkg-config is not installed.
*** Compilation will now be attempted and if it works you can ignore this message. In
*** particular, this should be the case on Mac where zlib is built in or pkg-config
*** is not installed. However, if compilation fails, try 'locate zlib.h zconf.h' and
*** ensure the zlib development library is installed :
***   deb: zlib1g-dev (Debian, Ubuntu, ...)
***   rpm: zlib-devel (Fedora, EPEL, ...)
***   There is a zlib in brew for OSX but the built in zlib should work.
*** Note that zlib is required to compile R itself so you may find the advice in the R-admin
*** guide helpful regarding zlib. On Debian/Ubuntu, zlib1g-dev is a dependency of r-base as
*** shown by 'apt-cache showsrc r-base | grep ^Build-Depends | grep zlib', and therefore
*** 'sudo apt-get build-dep r-base' should be sufficient too.
*** To silence this message, please ensure that :
***   1) 'pkg-config --exists zlib' succeeds (i.e. $? -eq 0)
***   2) 'pkg-config --libs zlib' contains -lz
*** Compilation will now be attempted ...
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
*** OpenMP not supported! data.table uses OpenMP to automatically
***   parallelize operations like sorting, grouping, file reading, etc.
*** For details on how to install the necessary toolchains on your OS see:
*** Continuing installation without OpenMP support...
*** Compilation without compression support in fwrite
** libs
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include -Xclang -fopenmp  -DNOZLIB -fPIC  -falign-functions=64 -Wall -g -O2  -c assign.c -o assign.o
In file included from assign.c:1:
In file included from ./data.table.h:1:
./myomp.h:2:12: fatal error: 'omp.h' file not found
  #include <omp.h>
1 error generated.
make: *** [assign.o] Error 1
ERROR: compilation failed for package ‘data.table’
* removing ‘/Volumes/GoogleDrive-114494246111519559339/.shortcut-targets-by-id/1zKSXwMLk4PD0AIhuLsac6eSCUrefwgKP/2021-Transportation/Connor/atlas_veh_choice/renv/staging/1/data.table’
R is currently configured to use a compiler that does not have OpenMP support.
You may need to disable OpenMP, or update your compiler toolchain.
Please see for a related discussion.

- "clang: error: unsupported option '-fopenmp'"
Error: install of package 'data.table' failed [error code 1]

I do not get this error when compiling the package from source outside an renv. I have tried to compile a couple of other packages from source as well, without success. The error message is not always the same, but the failure is consistent. System Info below:

R version 4.2.0 (2022-04-22)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.4

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.0 tools_4.2.0    renv_0.15.5 

It seems you are missing several system dependencies and you are running on a M1 Mac, I have no experience with M1 (ARM) systems but you can look into how to install these software dependencies in your specific system or hopefully someone else here with experience working with the M1 chip might be able to help you.

I am on an M1 Mac, but the dependencies are installed on my machine because I can compile these packages outside of an renv project. It's only within renv that R cannot find these dependencies.

If that is the case I think you would have better luck by formally filing an issue report on the GitHub repository for renv

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.