Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Rcpp dependency with cpp11 #299

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pachadotdev
Copy link

Dear Posit Team,

I hope you are doing well.

I spent most of my night awake trying to fix this error that chased me for a few days: When I try to install "devtools" in the Niagara cluster, I get this error

> install.packages("Rcpp")
trying URL 'https://packagemanager.posit.co/cran/__linux__/jammy/latest/src/contrib/Rcpp_1.0.13.tar.gz'
Content type 'binary/octet-stream' length 3438451 bytes (3.3 MB)
==================================================
downloaded 3.3 MB

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘Ubuntu clang version 19.1.3 (++20241031083547+ab51eccf88f5-1~exp1~20241031083703.58)’
clang++-19 -stdlib=libc++ -I"/opt/R/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -Wall -O3 -pedantic  -c api.cpp -o api.o
clang++-19 -stdlib=libc++ -I"/opt/R/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -Wall -O3 -pedantic  -c attributes.cpp -o attributes.o
clang++-19 -stdlib=libc++ -I"/opt/R/lib/R/include" -DNDEBUG -I../inst/include/  -I/usr/local/include    -fpic  -Wall -O3 -pedantic  -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));                                                       /...
      |                              ^~~~~~~~~~~~~~~
      |                              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/R/lib/R/include/Rinternals.h:290:15: note: 'VECTOR_PTR' declared here
  290 | NORET SEXP * (VECTOR_PTR)(SEXP x);
      |               ^
1 error generated.
make: *** [/opt/R/lib/R/etc/Makeconf:204: barrier.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/opt/R/lib/R/library/Rcpp’

The downloaded source packages are in
        ‘/tmp/RtmpYC6Btl/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("Rcpp") :
  installation of package ‘Rcpp’ had non-zero exit status

I have tried using Docker images and building R from source.

After replicating Niagara's configuration, which is CentOS with clang 19, I realised I had to install Rcpp from GitHub (i.e., using "remotes"), which is something I cannot do in the cluster (my account has limited permissions and TI is very strict).

My solution is this PR with minimal changes, adhering to your coding style, and that also features unit tests.

I hope you can accept it.

Please let me know if I have to change anything and I will do it promply.

It is not your fault, but I was severely mistreated on Stackoverflow for asking about this. I spent days figuring out my own solution for this, and my PR fixed the issues in the Niagara cluster by replacing the "Rcpp" dependency by "cpp11". I am just a (former) Statistician doing a PhD in Political Science, not a computer expert.

Respectfully,
Mauricio Pacha Vargas Sepulveda

@pachadotdev pachadotdev changed the title USE CPP11 !!!!!! Replace Rcpp dependency with cpp11 Nov 2, 2024
Copy link
Member

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can omit testing Rcpp loading with pkgload.

I'm not sure why you couldn't install pkgload because of Rcpp, especially since it's only a "suggested" package, not "imported", so it's not a requirement for simple installation.

DESCRIPTION Outdated Show resolved Hide resolved
NEWS.md Show resolved Hide resolved
@DavisVaughan
Copy link
Member

In Rcpp the guard for VECTOR_PTR_RO was previously set incorrectly. It has been fixed already in cran Rcpp of 1.0.13-1
RcppCore/Rcpp@3ae789b

Co-authored-by: Lionel Henry <lionel.hry@proton.me>
@pachadotdev
Copy link
Author

I don't think we can omit testing Rcpp loading with pkgload.

I'm not sure why you couldn't install pkgload because of Rcpp, especially since it's only a "suggested" package, not "imported", so it's not a requirement for simple installation.

ok, could it be possible to add my contribution in "parallel"?

@pachadotdev
Copy link
Author

I don't think we can omit testing Rcpp loading with pkgload.

I'm not sure why you couldn't install pkgload because of Rcpp, especially since it's only a "suggested" package, not "imported", so it's not a requirement for simple installation.

Niagara (the server) is very particular. It uses something called R-batteries-included that runs on a modified CentOS. If anything works there, it works anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants