3

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

  • Compiling V8 from source on Gentoo works perfectly fine using the official instructions (v8.dev/docs/build), I do it every day. That said, it's not clear to me what exactly v8-r requires (shared library libv8.so? headers in /usr/include? both? other?), so I don't know what you'd have to do to satisfy those dependencies. – jmrk Jul 15 '20 at 09:30
  • thanks for this, I try it again. r-stan needs v8 header files and a hared library libv8.so – Sven Garbade Jul 15 '20 at 12:37
  • To build the V8 R package, you might need the V8 library headers, but my guess is that once the V8 R package is built, rstan only needs the libv8.so at runtime. – Ben Goodrich Jul 16 '20 at 02:30

2 Answers2

5

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:

Jeroen Ooms
  • 31,998
  • 35
  • 134
  • 207
1

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.