ITADN

Installation fails only within isolated precommit environmnt

#630Opencaldwellst 创建于 2025-06-20
C
caldwellstcommented
**Before filing a bug** - [x] I have installed the latest dev version of {precommit} with `remotes::install_github('lorenzwalthert/precommit')` - [x] I have installed the latest hook revisions (update with `precommit::autoupdate()`) - [x] I have installed the latest release of the upstream Python framework pre-comit as described under the [update instructions](https://lorenzwalthert.github.io/precommit/dev/articles/precommit.html#update). **stringi generates error when installing hooks** I am trying to use the `style-files` and `lintr` hooks, which I have used in the past successfully many times (on previous machines). However, the installation breaks because I encounter errors when installing `{stringi}`. It seems to be an initial within the C++ compilers, however, my comparison of logs between running `install.packages("stringi")` successfully and the `{renv}` logs shows no difference in the identified compilers or commands. Below is how I can reproduce it. Strangely, I can reproduce this directly on a UTM virtual machine, so is not unique to my machine, and myabe has something to do with my installation setup of `llvm` and `gcc`? **To Reproduce** Minimal yaml: ```yaml repos: - repo: https://github.com/lorenzwalthert/precommit rev: v0.4.3.9008 hooks: - id: style-files - id: lintr ``` I have setup `pre-commit` using `uv add pre-commit` and then running `uv run pre-commit install --install-hooks`. This is the truncated log: ``` pre-commit version: 4.2.0 git --version: git version 2.49.0 sys.version: 3.13.1 (main, Dec 6 2024, 20:13:21) [Clang 18.1.8 ] sys.executable: /Users/seth.caldwell/repos/r_test/.venv/bin/python os.name: posix sys.platform: darwin ** using staged installation checking for R_HOME... /opt/homebrew/Cellar/r/4.5.1/lib/R checking for R... /opt/homebrew/Cellar/r/4.5.1/lib/R/bin/R checking for endianness... little checking for cat... /bin/cat checking whether the C++ compiler works... yes checking for C++ compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C++... yes accepts -g... yes checking for /opt/homebrew/opt/llvm/bin/clang++ option to enable C++11 features... none needed checking whether the C++ compiler supports the 'long long' type... yes checking whether the compiler implements namespaces... yes checking whether the compiler supports the Standard Template Library... yes checking whether std::map is available... yes checking for pkg-config... /opt/homebrew/bin/pkg-config checking with 'pkg-config' for the system ICU4C (icu-i18n icu-uc)... no *** pkg-config did not detect ICU4C-devel libraries installed *** Trying with 'standard' fallback flags checking whether an ICU4C-based project can be built... no *** This version of ICU4C cannot be used. *** Using the ICU 74 bundle that comes with 'stringi'. checking whether we may compile src/icu74/common/putil.cpp... yes checking whether we may compile src/icu74/i18n/number_affixutils.cpp... yes checking whether alignof(std::max_align_t) is available... yes checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for elf.h... no checking whether the ICU data library is available... icu74/data/icudt74l.dat.xz exists configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/uconfig_local.h config.status: creating src/install.libs.R *** stringi configure summary: ICU_FOUND=0 ICUDT_DIR=icu74/data ICU_BUNDLE_VERSION=74 ICUDT_ENDIANNESS=little STRINGI_CXXSTD= STRINGI_CXXFLAGS= -fPIC STRINGI_CPPFLAGS=-I. -UDEBUG -DNDEBUG -Iicu74 -Iicu74/unicode -Iicu74/common -Iicu74/i18n -DU_STATIC_IMPLEMENTATION -DU_COMMON_IMPLEMENTATION -DU_I18N_IMPLEMENTATION -D_REENTRANT -DUCONFIG_USE_LOCAL STRINGI_LDFLAGS= STRINGI_LIBS= *** Compiler settings used: CXX=/opt/homebrew/opt/llvm/bin/clang++ LD=/opt/homebrew/opt/llvm/bin/clang++ CXXFLAGS=-g -O2 CPPFLAGS=-isystem /opt/homebrew/opt/llvm/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/opt/gettext/include LDFLAGS= LIBS= ** libs using C++ compiler: ‘Homebrew clang version 20.1.7’ using SDK: ‘MacOSX15.4.sdk’ /opt/homebrew/opt/llvm/bin/clang++ -I"/opt/homebrew/Cellar/r/4.5.1/lib/R/include" -DNDEBUG -I. -UDEBUG -DNDEBUG -Iicu74 -Iicu74/unicode -Iicu74/common -Iicu74/i18n -DU_STATIC_IMPLEMENTATION -DU_COMMON_IMPLEMENTATION -DU_I18N_IMPLEMENTATION -D_REENTRANT -DUCONFIG_USE_LOCAL -isystem "/opt/homebrew/opt/llvm/include" -isysroot "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" -I"/opt/homebrew/opt/gettext/include" -fPIC -fPIC -g -O2 -c stri_brkiter.cpp -o stri_brkiter.o In file included from stri_brkiter.cpp:32: In file included from ./stri_stringi.h:36: In file included from ./stri_external.h:68: In file included from /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R.h:70: /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R_ext/Boolean.h:62:36: warning: unknown warning group '-Wfixed-enum-extension', ignored [-Wunknown-warning-option] 62 | # pragma clang diagnostic ignored "-Wfixed-enum-extension" | ^ In file included from stri_brkiter.cpp:32: In file included from ./stri_stringi.h:36: In file included from ./stri_external.h:68: In file included from /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R.h:73: /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R_ext/Error.h:58:3: error: 'noreturn' attribute does not appear on the first declaration 58 | [[noreturn]] void Rf_error(const char *, ...) R_PRINTF_FORMAT(1, 2); | ^ ./uconfig_local.h:55:23: note: previous declaration is here 55 | extern "C" void NORET Rf_error(const char *, ...); | ^ 1 warning and 1 error generated. make: *** [stri_brkiter.o] Error 1 ERROR: compilation failed for package ‘stringi’ ``` And here is the successful log from running `install.packages("stringi")`. I can also successfully run `renv::install("stringi")` if necessary, but haven't logged that (can if helpful). ``` * installing *source* package ‘stringi’ ... ** this is package ‘stringi’ version ‘1.8.7’ ** package ‘stringi’ successfully unpacked and MD5 sums checked ** using staged installation checking for R_HOME... /opt/homebrew/Cellar/r/4.5.1/lib/R checking for R... /opt/homebrew/Cellar/r/4.5.1/lib/R/bin/R checking for endianness... little checking for cat... /bin/cat checking whether the C++ compiler works... yes checking for C++ compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C++... yes checking whether /opt/homebrew/opt/llvm/bin/clang++ accepts -g... yes checking for /opt/homebrew/opt/llvm/bin/clang++ option to enable C++11 features... none needed checking whether the C++ compiler supports the 'long long' type... yes checking whether the compiler implements namespaces... yes checking whether the compiler supports the Standard Template Library... yes checking whether std::map is available... yes checking for pkg-config... /opt/homebrew/bin/pkg-config checking with 'pkg-config' for the system ICU4C (icu-i18n icu-uc)... no *** pkg-config did not detect ICU4C-devel libraries installed *** Trying with 'standard' fallback flags checking whether an ICU4C-based project can be built... no *** This version of ICU4C cannot be used. *** Using the ICU 74 bundle that comes with 'stringi'. checking whether we may compile src/icu74/common/putil.cpp... yes checking whether we may compile src/icu74/i18n/number_affixutils.cpp... yes checking whether alignof(std::max_align_t) is available... yes checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for elf.h... no checking whether the ICU data library is available... icu74/data/icudt74l.dat.xz exists configure: creating ./config.status config.status: creating src/Makevars config.status: creating src/uconfig_local.h config.status: creating src/install.libs.R *** stringi configure summary: ICU_FOUND=0 ICUDT_DIR=icu74/data ICU_BUNDLE_VERSION=74 ICUDT_ENDIANNESS=little STRINGI_CXXSTD= STRINGI_CXXFLAGS= -fPIC STRINGI_CPPFLAGS=-I. -UDEBUG -DNDEBUG -Iicu74 -Iicu74/unicode -Iicu74/common -Iicu74/i18n -DU_STATIC_IMPLEMENTATION -DU_COMMON_IMPLEMENTATION -DU_I18N_IMPLEMENTATION -D_REENTRANT -DUCONFIG_USE_LOCAL STRINGI_LDFLAGS= STRINGI_LIBS= *** Compiler settings used: CXX=/opt/homebrew/opt/llvm/bin/clang++ LD=/opt/homebrew/opt/llvm/bin/clang++ CXXFLAGS=-g -O2 CPPFLAGS=-isystem /opt/homebrew/opt/llvm/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/opt/gettext/include LDFLAGS= LIBS= ** libs using C++ compiler: ‘Homebrew clang version 20.1.7’ using SDK: ‘MacOSX15.4.sdk’ /opt/homebrew/opt/llvm/bin/clang++ -I"/opt/homebrew/Cellar/r/4.5.1/lib/R/include" -DNDEBUG -I. -UDEBUG -DNDEBUG -Iicu74 -Iicu74/unicode -Iicu74/common -Iicu74/i18n -DU_STATIC_IMPLEMENTATION -DU_COMMON_IMPLEMENTATION -DU_I18N_IMPLEMENTATION -D_REENTRANT -DUCONFIG_USE_LOCAL -isystem "/opt/homebrew/opt/llvm/include" -isysroot "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" -I"/opt/homebrew/opt/gettext/include" -fPIC -fPIC -g -O2 -c stri_brkiter.cpp -o stri_brkiter.o In file included from stri_brkiter.cpp:32: In file included from ./stri_stringi.h:36: In file included from ./stri_external.h:68: In file included from /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R.h:70: /opt/homebrew/Cellar/r/4.5.1/lib/R/include/R_ext/Boolean.h:62:36: warning: unknown warning group '-Wfixed-enum-extension', ignored [-Wunknown-warning-option] 62 | # pragma clang diagnostic ignored "-Wfixed-enum-extension" | ^ 1 warning generated. ``` **Expected behavior** I would expect this to work, as the C++ compilers are identical and clearly pulling from my `~/.R/Makevars`. But my guess is that something happens within `pre-commit` that I don't understand. **Additional context** - Here is `my sessionInfo()` that gives some platform information: ``` R version 4.5.1 (2025-06-13) Platform: aarch64-apple-darwin24.4.0 Running under: macOS Sequoia 15.5 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /opt/homebrew/Cellar/r/4.5.1/lib/R/lib/libRlapack.dylib; LAPACK version 3.12.1 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: Europe/London tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.5.1 tools_4.5.1 rstudioapi_0.17.1 ``` Here is my `~/.R/Makevars`: ``` XCBASE:=$(shell xcrun --show-sdk-path) LLVMBASE:=$(shell brew --prefix llvm) GCCBASE:=$(shell brew --prefix gcc) GETTEXT:=$(shell brew --prefix gettext) CC=$(LLVMBASE)/bin/clang CXX=$(LLVMBASE)/bin/clang++ CXX11=$(LLVMBASE)/bin/clang++ CXX14=$(LLVMBASE)/bin/clang++ CXX17=$(LLVMBASE)/bin/clang++ CXX1X=$(LLVMBASE)/bin/clang++ CPPFLAGS=-isystem "$(LLVMBASE)/include" -isysroot "$(XCBASE)" -I"$(GETTEXT)/include" LDFLAGS=-L"$(LLVMBASE)/lib" -lomp -L"$(GETTEXT)/lib" --sysroot="$(XCBASE)" FC=$(GCCBASE)/bin/gfortran F77=$(GCCBASE)/bin/gfortran FLIBS=-L$(GCCBASE)/lib/gcc/9/ -lm ```
1 条评论