Cannot install V8 package at rstudio IDE

I am on Amazon Linux 2, and having trouble to install V8 R package.

installed devtoolset-9 as https://support.posit.co/hc/en-us/articles/360006145413-RStudio-Workbench-RStudio-Server-Pro-with-devtoolset-enabled

system("gcc --version")
gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

but V8 still cannot compile.

install.packages("V8")
Installing package into ‘/r01/data/byang/R/x86_64-pc-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/V8_4.4.0.tar.gz'
Content type 'application/x-gzip' length 678520 bytes (662 KB)
==================================================
downloaded 662 KB

  • installing source package ‘V8’ ...
    ** package ‘V8’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Using default C++11 compiler:
    Using CXXCPP=g++ -std=gnu++11 -E
    Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
    Using PKG_LIBS=-lv8 -lv8_libplatform
    Running feature test for pointer compression...
    In file included from /usr/include/v8.h:30,
    from tools/test.cpp:2:
    /usr/include/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:50: error: template argument 2 is invalid
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^
    /usr/include/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~
    Enabling pointer compression
    Running feature test for sandbox...
    In file included from /usr/include/v8.h:30,
    from tools/test.cpp:2:
    /usr/include/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:50: error: template argument 2 is invalid
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^
    /usr/include/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~
    In file included from /usr/include/v8.h:30,
    from tools/version.cpp:1:
    /usr/include/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:50: error: template argument 2 is invalid
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^
    /usr/include/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~
    ./configure: line 155: ./v8version: No such file or directory
    ** libs
    using C++ compiler: ‘g++ (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)’
    using C++11
    rm -f V8.so RcppExports.o bindings.o
    g++ -std=gnu++11 -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -DV8_COMPRESS_POINTERS -I'/r01/data/byang/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include' -I/usr/local/include -fvisibility=hidden -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    In file included from /usr/include/v8.h:30,
    from V8_types.h:1,
    from RcppExports.cpp:4:
    /usr/include/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~~~~~
    | remove_cv
    /usr/include/v8-internal.h:492:50: error: template argument 2 is invalid
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^
    /usr/include/v8-internal.h:492:63: error: ‘::Perform’ has not been declared
    492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);
    | ^~~~~~~
    make: *** [/opt/R/4.3.1/lib/R/etc/Makeconf:198: RcppExports.o] Error 1
    ERROR: compilation failed for package ‘V8’
  • removing ‘/r01/data/byang/R/x86_64-pc-linux-gnu-library/4.3/V8’
    Warning in install.packages :
    installation of package ‘V8’ had non-zero exit status

The downloaded source packages are in
‘/tmp/RtmpYrtOY4/downloaded_packages’

I stuck here for a long time. Appreciate any help/suggestion.

Thanks a lot.

I think V8 needs the nodejs-libs package on RHEL 9. If you indeed have V8 3.14, that is very old, and probably not going to work.