Unable to install build tools when doing devtools::check()

I'm unable to get devtools::check() to complete. If I create a new R package in Rstudio (File->New Project->New Directory->R Package) and then do devtools::check(), I get a popup saying "Install Build Tools Building R package from source requires installation of additional build tools. Do you want to install the additional tools now?" I click Yes and get an error...

> check()
══ Building ═════════════════════════════════════════════════════
Setting env vars:
• CFLAGS    : -Wall -pedantic
• CXXFLAGS  : -Wall -pedantic
• CXX11FLAGS: -Wall -pedantic
• CXX14FLAGS: -Wall -pedantic
• CXX17FLAGS: -Wall -pedantic
• CXX20FLAGS: -Wall -pedantic
── R CMD build ──────────────────────────────────────────────────
✔  checking for file ‘/Users/pschloss/Desktop/testR/DESCRIPTION’ ...
─  preparing ‘testR’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Omitted ‘LazyData’ from DESCRIPTION
─  building ‘testR_0.1.0.tar.gz’
   
══ Checking ═════════════════════════════════════════════════════
Setting env vars:
• _R_CHECK_CRAN_INCOMING_REMOTE_               : FALSE
• _R_CHECK_CRAN_INCOMING_                      : FALSE
• _R_CHECK_FORCE_SUGGESTS_                     : FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
• NOT_CRAN                                     : true
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

Then I do as it asks and get the same popup window and error.

> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD \
  SHLIB foo.c
using C compiler: ‘clang version 17.0.6’
using SDK: ‘MacOSX14.4.sdk’
clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c foo.c -o foo.o
clang -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: framework not found CoreFoundation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Library/Frameworks/R.framework/Resources/share/make/shlib.mk:10: foo.so] Error 1
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

devtools::install() works just fine. I've tried this with the CRAN and dev versions of devtools and get the same result. I'm in Mac OS X 14.4 (23E214) running R 4.3.3 with RStudio 2023.12.1 Build 402, which it says is the latest version. Any ideas what I'm doing wrong here?

> session_info()
─ Session info ────────────────────────────────────────────────
 setting  value
 version  R version 4.3.3 (2024-02-29)
 os       macOS Sonoma 14.4
 system   x86_64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/Detroit
 date     2024-03-13
 rstudio  2023.12.1+402 Ocean Storm (desktop)
 pandoc   2.19.2 @ /opt/homebrew/bin/pandoc

─ Packages ────────────────────────────────────────────────────
 package     * version    date (UTC) lib source
 cachem        1.0.8      2023-05-01 [1] CRAN (R 4.3.0)
 callr         3.7.5      2024-02-19 [1] CRAN (R 4.3.2)
 cli           3.6.2      2023-12-11 [1] CRAN (R 4.3.0)
 curl          5.2.1      2024-03-01 [1] CRAN (R 4.3.2)
 desc          1.4.3      2023-12-10 [1] CRAN (R 4.3.0)
 devtools    * 2.4.5.9000 2024-03-13 [1] Github (r-lib/devtools@c3fa3df)
 digest        0.6.35     2024-03-11 [1] CRAN (R 4.3.2)
 ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.3.0)
 fansi         1.0.6      2023-12-08 [1] CRAN (R 4.3.0)
 fastmap       1.1.1      2023-02-24 [1] CRAN (R 4.3.0)
 fs            1.6.3      2023-07-20 [1] CRAN (R 4.3.0)
 glue          1.7.0      2024-01-09 [1] CRAN (R 4.3.0)
 lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.3.0)
 magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.3.0)
 memoise       2.0.1      2021-11-26 [1] CRAN (R 4.3.0)
 pillar        1.9.0      2023-03-22 [1] CRAN (R 4.3.0)
 pkgbuild      1.4.3      2023-12-10 [1] CRAN (R 4.3.0)
 pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.3.0)
 pkgload       1.3.4      2024-01-16 [1] CRAN (R 4.3.0)
 prettyunits   1.2.0      2023-09-24 [1] CRAN (R 4.3.0)
 processx      3.8.3      2023-12-10 [1] CRAN (R 4.3.0)
 ps            1.7.6      2024-01-18 [1] CRAN (R 4.3.0)
 purrr         1.0.2      2023-08-10 [1] CRAN (R 4.3.0)
 R6            2.5.1      2021-08-19 [1] CRAN (R 4.3.0)
 rcmdcheck     1.4.0      2021-09-27 [1] CRAN (R 4.3.0)
 remotes       2.4.2.1    2023-07-18 [1] CRAN (R 4.3.0)
 rlang         1.1.3      2024-01-10 [1] CRAN (R 4.3.0)
 rprojroot     2.0.4      2023-11-05 [1] CRAN (R 4.3.0)
 rstudioapi    0.15.0     2023-07-07 [1] CRAN (R 4.3.0)
 sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.3.0)
 tibble        3.2.1      2023-03-20 [1] CRAN (R 4.3.0)
 usethis     * 2.2.3      2024-02-19 [1] CRAN (R 4.3.2)
 utf8          1.2.4      2023-10-22 [1] CRAN (R 4.3.0)
 vctrs         0.6.5      2023-12-01 [1] CRAN (R 4.3.0)
 withr         3.0.0      2024-01-16 [1] CRAN (R 4.3.0)
 xopen         1.0.0      2018-09-17 [1] CRAN (R 4.3.0)

 [1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library

───────────────────────────────────────────────────────────────
1 Like

What does devtools::dev_sitrep() return?

Are you using Xcode or the command line tools? What is the output of

xcode-select -p

?

Here's what I'm getting...

> devtools::dev_sitrep()
── R ────────────────────────────────────────────────────────────
• version: 4.3.3
• path: '/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/'
── RStudio ──────────────────────────────────────────────────────
• version: 2023.12.1.402
── devtools ─────────────────────────────────────────────────────
• version: 2.4.5
── dev package ──────────────────────────────────────────────────
• package: 'testR'
• path: '/Users/pschloss/Desktop/testR/'
✔ All checks passed

Command line tools...

~ $ xcode-select --install
xcode-select: note: Command line tools are already installed. Use "Software Update" in System Settings or the softwareupdate command line interface to install updates
~ $ xcode-select -p
/Library/Developer/CommandLineTools

Also, everything appears to be up to date under the Software Update in the System Settings

For what it's worth, it passes running R CMD CHECK

$ R CMD CHECK testR
* using log directory ‘/Users/pschloss/Desktop/testR.Rcheck’
* using R version 4.3.3 (2024-02-29)
* using platform: x86_64-apple-darwin20 (64-bit)
* R was compiled by
Apple clang version 14.0.0 (clang-1400.0.29.202)
GNU Fortran (GCC) 12.2.0
* running under: macOS Sonoma 14.4
* using session charset: UTF-8
* checking for file ‘testR/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘testR’ version ‘0.1.0’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... NOTE
Found the following hidden files and directories:
.gitignore
.Rproj.user
.git
These were most likely included in error. See section ‘Package
structure’ in the ‘Writing R Extensions’ manual.
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘testR’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
What license is it under?
Standardizable: FALSE
Checking should be performed on sources prepared by ‘R CMD build’.
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking LazyData ... NOTE
'LazyData' is specified without a 'data' directory
* checking examples ... OK
* checking PDF version of manual ... OK
* DONE

Status: 1 WARNING, 2 NOTEs
See
‘/Users/pschloss/Desktop/testR.Rcheck/00check.log’
for details.

That package does not seem to have any compiled code.

I wonder if the problems is some incompatibility between the very recent Xcode (CLT) or macOS and the R config.

Here are two things you can try. One is removing the -Wl,CoreFoundation part from the LIBINTL= line in /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/etc/Makeconf:

LIBINTL=   -Wl,-framework

You'll need sudo or a root shell to do that.

The other thing you could try is installing a slightly older version of the command line tools.

1 Like

Thanks @Gabor -

Unfortunately, neither idea did the trick. I modified the Makeconf file as you indicated and was still getting an error. Then I downgraded the command line tools from 15.3 to 15.1. I can't go earlier with my OS version. Here's the current error message with these changes...

> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB foo.c
using C compiler: ‘clang version 17.0.6’
using SDK: ‘MacOSX14.2.sdk’
clang -arch x86_64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/x86_64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c foo.c -o foo.o
clang -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/x86_64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
ld: framework not found -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Library/Frameworks/R.framework/Resources/share/make/shlib.mk:10: foo.so] Error 1
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

I also don't have any C++ code in my real package, is there anyway around having check attempt to install the build tools without throwing an error?

Sorry, removing the library from the Makeconf was a bad idea. Can you write it back, and then try again with the older command line tools?

Also, do you have anything in your personal Makevars file, at ~/.R/Makevars?

Do you have anything in your package's Makevars file?

I put the edit back in Makeconf and didn't have a personal or package Makevars file.

For some reason, I looked to see which location and version of clang was being used with system(which clang); system(clang --version). I noticed that for some reason it was trying to use the clang I had in my base conda environment. After cleaning out the base environment, putting the edit back in the Makeconf, and trying check() again, everything worked. I guess this is an illustration for why I shouldn't be installing stuff into the base environment!

Really sorry for all the hassle, but it does seem odd that it was using the conda version. I appreciate the help!

Thanks,
Pat

2 Likes

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.