Installing V8 required by rstan on gentoo

1.2k Views Asked by At

is there a way to install rstan on a Gentoo amd64 system? rstan depends on v8-r (https://cran.r-project.org/web/packages/V8/index.html), which depends on a v8 installation. I haven't found a working v8 ebuild, v8 failed to compile with didactic-duck ebuilds. I also tried nodejs, without success. Compiling v8 from source failed with "unsupported linux distro".

Thanks, Sven

2

There are 2 best solutions below

1
Jeroen Ooms On BEST ANSWER

UPDATE: as of the latest version of V8 you can use:

# For Linux: download libv8 during installation
Sys.setenv(DOWNLOAD_STATIC_LIBV8=1)
install.packages("V8")

This way, you can install the V8 package on any x64 Linux system, without separate system requirements. See also this post: https://ropensci.org/technotes/2020/11/12/installing-v8/


Original answer

The R package V8 simply needs libv8 headers and shared library. The best solution is to use the V8 engine from NodeJS, but this can only be done if NodeJS itself was built with the --shared option. I don't use Gentoo myself, but from the above I guess this is currently not the case.

You have to talk to the maintainer of the nodejs package in Gentoo, and ask them to enable shared libnode. Below some references about this from Fedora and Debian, that might get you started:

If you can't get this to work, you could also build libv8 yourself, but I have to warn you this is pretty painful because upstream changes their API and build system every few weeks.

Some working examples are:

0
Xavier Fernández i Marín On

Same problem here.

I am afraid I don't have an answer myself. If it helps, the furthest that I have gone is to install "nodejs" and then manually try to install V8 from source:

R CMD INSTALL --configure-vars='INCLUDE_DIR=/usr/include/node/deps/v8/include LIB_DIR=/usr/include/node/libplatform' V8_3.2.0.tar.gz

But CRAN complains about "cannot find -lv8_libplatform", and with other combinations of INCLUDE_DIR and LIB_DIR I have not succeeded.

I have also tried several ebuilds from didactic-duck and even one from petkovich.

Also, installing from source seems to be impossible.

What "nodejs" install is the following, in case someone else has an idea about how to combine INCLUDE_DIR and LIB_DIR, or at least to enlight whether with nodejs is enough, or a full v8 installation is needed:

/usr/include/node/v8-fast-api-calls.h
/usr/include/node/v8-internal.h
/usr/include/node/v8-platform.h
/usr/include/node/v8-profiler.h
/usr/include/node/v8-util.h
/usr/include/node/v8-value-serializer-version.h
/usr/include/node/v8-version-string.h
/usr/include/node/v8-version.h
/usr/include/node/v8-wasm-trap-handler-posix.h
/usr/include/node/v8-wasm-trap-handler-win.h
/usr/include/node/v8.h
/usr/include/node/v8config.h
/usr/include/node/deps/v8
/usr/include/node/deps/v8/include
/usr/include/node/libplatform/v8-tracing.h

Thank you very much.