r-lib / pkgbuild

Find tools needed to build R packages
https://pkgbuild.r-lib.org
Other
66 stars 35 forks source link

pkgbuild::check_build_tools(debug = TRUE) returns unintelligible results #136

Closed alexWhitworth closed 1 year ago

alexWhitworth commented 2 years ago

I'm trying to install XBART but getting uninterpretable diagnostics from pkgbuild. I've also tried git clone <XBART> and installing from local (devtools::install("XBART")) without success

Please advise! Thanks

>  devtools::install_github("r-lib/pkgbuild")
...
* DONE (pkgbuild)

# try via devtools
> devtools::install("XBART")
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

# try via remotes
> remotes::install_github("JingyuHe/XBART")
Downloading GitHub repo JingyuHe/XBART@HEAD
Error: Failed to install 'XBART' from GitHub:
  Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

# diagnose
> 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
/usr/local/opt/gcc/bin/g++-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/opt/llvm/include -fopenmp   -fPIC  -Wall -g -O2  -c foo.c -o foo.o
/usr/local/opt/gcc/bin/g++-11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -I/usr/local/opt/llvm/include -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation

Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

R + Computer info

R> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin20.6.0 (64-bit)
Running under: macOS Big Sur 11.6.5

Matrix products: default
BLAS:   /usr/local/Cellar/openblas/0.3.20/lib/libopenblasp-r0.3.20.dylib
LAPACK: /usr/local/Cellar/r/4.1.3/lib/R/lib/libRlapack.dylib

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

$ gfortran --version
GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0

$ which brew, gcc, gfortran, gettext
/usr/local/bin/brew
/usr/bin/gcc
/usr/local/bin/gfortran
/usr/local/bin/gettext

llvm 13.0.1_1 is already installed and up-to-date.
libomp 14.0.0 is already installed and up-to-date.

Makevars

CBASE=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
GCCBASE=/usr/local/opt/gcc
GETTEXT=/usr/local/bin/gettext
GCCVERSION=11
LOC_FORTRAN=/usr/local/opt/gfortran
LOC_LLVM=/usr/local/opt/llvm

LDFLAGS=-L/usr/local/opt/llvm/lib
CPPFLAGS=-I$(LOC_LLVM)/include
LDFLAGS=-I$(LOC_LLVM)/include
CPPFLAGS += -fopenmp
# LDFLAGS += -lomp

CC=$(GCCBASE)/bin/g++-${GCCVERSION}
CXX=$(GCCBASE)/bin/g++-${GCCVERSION}
CXX11=$(GCCBASE)/bin/g++-${GCCVERSION}
CXX14=$(GCCBASE)/bin/g++-${GCCVERSION}
CXX17=$(GCCBASE)/bin/g++-${GCCVERSION}
CXX1X=$(GCCBASE)/bin/g++-${GCCVERSION}

FC=$(LOC_FORTRAN)
F77=$(LOC_FORTRAN)
FLIBS=-L$(GCCBASE)/lib/gcc/${GCCVERSION}/ -lm -lgfortran
gaborcsardi commented 2 years ago

What if you try to install it without pkgbuild? E.g. with

R CMD INSTALL 

from the command line?

alexWhitworth commented 2 years ago

@gaborcsardi Then it installs without incident. Now I feel stupid... thank you

gaborcsardi commented 2 years ago

That means that there is a bug in pkgbuild then, so I'll reopen this. I'll try to reproduce this and might ask you about your setup if I can't.

alexWhitworth commented 2 years ago

Ah... so less stupid :). From clean session, after loading devtools, remotes, Rcpp, RcppArmadillo:

R> sessioninfo::package_info()
 package       * version    date (UTC) lib source
 brio            1.1.3      2021-11-30 [1] CRAN (R 4.1.0)
 cachem          1.0.6      2021-08-19 [1] CRAN (R 4.1.0)
 callr           3.7.0      2021-04-20 [1] CRAN (R 4.1.0)
 cli             3.2.0      2022-02-14 [1] CRAN (R 4.1.2)
 crayon          1.5.1      2022-03-26 [1] CRAN (R 4.1.2)
 data.table      1.14.2     2021-09-27 [1] CRAN (R 4.1.0)
 dbarts          0.9-22     2022-03-29 [1] CRAN (R 4.1.2)
 desc            1.4.1      2022-03-06 [1] CRAN (R 4.1.2)
 devtools      * 2.4.3      2021-11-30 [1] CRAN (R 4.1.0)
 ellipsis        0.3.2      2021-04-29 [1] CRAN (R 4.1.0)
 fastmap         1.1.0      2021-01-25 [1] CRAN (R 4.1.0)
 fs              1.5.2      2021-12-08 [1] CRAN (R 4.1.0)
 glue            1.6.2      2022-02-24 [1] CRAN (R 4.1.2)
 knitr           1.38       2022-03-25 [1] CRAN (R 4.1.2)
 lifecycle       1.0.1      2021-09-24 [1] CRAN (R 4.1.0)
 magrittr        2.0.3      2022-03-30 [1] CRAN (R 4.1.2)
 memoise         2.0.1      2021-11-26 [1] CRAN (R 4.1.0)
 pkgbuild        1.3.1.9000 2022-04-08 [1] Github (r-lib/pkgbuild@a22b6a3)
 pkgload         1.2.4      2021-11-30 [1] CRAN (R 4.1.0)
 prettyunits     1.1.1      2020-01-24 [1] CRAN (R 4.1.0)
 processx        3.5.3      2022-03-25 [1] CRAN (R 4.1.2)
 ps              1.6.0      2021-02-28 [1] CRAN (R 4.1.0)
 purrr           0.3.4      2020-04-17 [1] CRAN (R 4.1.0)
 R6              2.5.1      2021-08-19 [1] CRAN (R 4.1.0)
 Rcpp          * 1.0.8.3    2022-03-17 [1] CRAN (R 4.1.2)
 RcppArmadillo * 0.11.0.0.0 2022-04-04 [1] CRAN (R 4.1.2)
 remotes       * 2.4.2      2021-11-30 [1] CRAN (R 4.1.0)
 rlang           1.0.2      2022-03-04 [1] CRAN (R 4.1.2)
 rprojroot       2.0.3      2022-04-02 [1] CRAN (R 4.1.2)
 rstudioapi      0.13       2020-11-12 [1] CRAN (R 4.1.0)
 sessioninfo     1.2.2      2021-12-06 [1] CRAN (R 4.1.0)
 testthat        3.1.3      2022-03-29 [1] CRAN (R 4.1.2)
 usethis       * 2.1.5      2021-12-09 [1] CRAN (R 4.1.0)
 withr           2.5.0      2022-03-03 [1] CRAN (R 4.1.2)
 xfun            0.30       2022-03-02 [1] CRAN (R 4.1.2)
alexWhitworth commented 2 years ago

Same problem with XBCF. Again, was able to build via R CMD build, R CMD install

gaborcsardi commented 1 year ago

@alexWhitworth If you still have this issue (and still want to solve it :), then there is a potential workaround with the current devel version of pkgbuild.

You can set the pkgbuild.has_compiler option to TRUE, and then pkgbuild does not try to detect if the compiler works. The installation might still fail, of course, but hopefully with some better errors. Can you try this?

alexWhitworth commented 1 year ago

@gaborcsardi Thanks, but I just use R CMD build instead.