R4.4.2 Rcpp incompatibility with latest fixed reference
**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).
**Describe the bug**
Recently my local machine brew updated to R 4.4.2. This caused the `precommit` R environment initialisation to fail due to an Rcpp compilation error:
```
stderr:
Error: Error installing package 'Rcpp':
================================
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
using SDK: ‘MacOSX15.2.sdk’
clang++ -std=gnu++17 -I"/opt/homebrew/Cellar/r/4.4.2_2/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c api.cpp -o api.o
clang++ -std=gnu++17 -I"/opt/homebrew/Cellar/r/4.4.2_2/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c attributes.cpp -o attributes.o
clang++ -std=gnu++17 -I"/opt/homebrew/Cellar/r/4.4.2_2/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c barrier.cpp -o barrier.o
barrier.cpp:74:30: error: use of undeclared identifier 'VECTOR_PTR_RO'; did you mean 'VECTOR_PTR'?
74 | return const_cast<SEXP*>(RCPP_VECTOR_PTR(x)); // #nocov end
| ^~~~~~~~~~~~~~~
| VECTOR_PTR
../inst/include/Rcpp/r/compat.h:34:26: note: expanded from macro 'RCPP_VECTOR_PTR'
34 | # define RCPP_VECTOR_PTR VECTOR_PTR_RO
| ^
/opt/homebrew/Cellar/r/4.4.2_2/lib/R/include/Rinternals.h:290:15: note: 'VECTOR_PTR' declared here
290 | NORET SEXP * (VECTOR_PTR)(SEXP x);
| ^
1 error generated.
make: *** [barrier.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
```
After doing some digging, this seems to be a manifestation of this [issue](https://github.com/RcppCore/Rcpp/issues/1341) related to `Rcpp`. This problem was resolved in the `Rcpp` hotfix version `1.0.13-1` and is further covered in `1.0.14`.
In the latest fixed ref for `precommit` (and indeed, that which is defined following an `autoupgrade`) is `v0.4.3.9003`, within which the `renv` lock file that (from what I understand) is used to initialise the virtual environment for the hook itself uses `Rcpp` version `1.0.13`, and hence produces the above error. (See [here](https://github.com/lorenzwalthert/precommit/blob/241be974396e13b3e87699301ba44e6999934019/renv.lock#L78).)
In the `main` branch of `precommit`, `Rcpp` is pinned to version `1.0.14`, and indeed the virtual environment can be constructed successfully, and hooks appear to run as expected.
So my fix at the moment is to use the mutable ref `main`, but this isn't a perfect solution. If a tagged version of `precommit` was available with `Rcpp` bumped to `1.0.14`, that would be great.
Thanks a lot! 🙏
关闭于 2025-02-28 2 条评论