`renv` doesn't install `data.table` with OpenMP support

Hello everyone,

It is well-known that "properly" installing data.table on Mac is challenging. If one simply runs install.packages("data.table"), they will get the following message upon loading the library:

data.table 1.14.2 using 1 threads (see ?getDTthreads).  Latest news: r-datatable.com
**********
This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode.
This is a Mac. Please read https://mac.r-project.org/openmp/. Please engage with Apple and ask them for support. Check r-datatable.com for updates, and our Mac instructions here: https://github.com/Rdatatable/data.table/wiki/Installation. After several years of many reports of installation problems on Mac, it's time to gingerly point out that there have been no similar problems on Windows or Linux.
**********

Luckily, the developers of the data.table provide instructions on how to solve this issue. Having installed the GNU Fortran complier from CRAN and following other steps in the instruction, I can get the proper installation in RStudio, when I work outside a project and do not use renv. I would like to get it working in a project that uses renv. The actual installation step in R looks like this:

remove.packages("data.table")
install.packages("data.table", type = "source",
    repos = "https://Rdatatable.gitlab.io/data.table")

When I load the package using library(data.table) (outside any project in RStudio), I get the following message

data.table 1.14.3 IN DEVELOPMENT built 2021-12-21 03:03:48 UTC; root using 4 threads (see ?getDTthreads).  Latest news: r-datatable.com

Now, I switch to one of my existing R Projects that have renv going on. I attempt to install data.tables using the same approach:

remove.packages("data.table")
renv::purge("data.table") # remove data.table from cache, to prevent re-installing from the 'bad' installations
install.packages("data.table", type = "source",
    repos = "https://Rdatatable.gitlab.io/data.table")

For some reason, the installation is

  • Very quick
  • Uses 'https://cran.rstudio.com/bin/macosx/contrib/4.1/data.table_1.14.2.tgz' instead of the repo provided
  • installs a different version
  • Most importantly, does not result in a correct installation with OpenMP support enabled.

Here is the message upon installation:

Installing package into β€˜/Users/dmitrysorokin/Documents/Projects/name_of_project/renv/library/R-4.1/x86_64-apple-darwin17.0’
(as β€˜lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/data.table_1.14.2.tgz'
Content type 'application/x-gzip' length 2336276 bytes (2.2 MB)
==================================================
downloaded 2.2 MB

The message upon loading the library is the same as at the top of the post. My session info from the R Project that uses renv right after this step is

> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

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

locale:
[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     

other attached packages:
[1] data.table_1.14.2

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

I would appreciate any help! Thank you very much in advance.

1 Like

This sounds like a big that has been fixed in the latest version of renv. Have you already tried updating renv?

Thank you, Kevin, the update solved the issue!

If you have another minute, do you mind me asking another related question? I was able to install data.tables properly in an RStudio project that uses renv. When I switch to another renv-managed project, data.tables have to be installed again, meaning that renv does not use a link to another project's library (I checked that by going to project > renv > library >... and saw that the data.table folder is not a link). Is this because I am installing a package from source, and it has to be compiled separately for each project?

Thank you very much for your help, I appreciate it!

This is mainly because the renv shim for install.packages() doesn't activate if you're trying to install packages using extra arguments to install.packages().

I'll need to think about ways to make this more straightforward; e.g. tools for explicitly requesting that a package be installed from (or moved into) the cache. (There are internal tools, but nothing public.)

1 Like

This topic was automatically closed 7 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.