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?
~ $ 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.
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?
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!