Problem installing Rstan 2.21 using R 4.0.1 on CentOS 7

Update: I asked system admin if they might install V8, and was told to try: scl enable devtoolset-9 bash
I still get the same error.

I cannot install the latest version of Rstan using R4.0.1 on CentOS 7 machine.
I followed the instructions found here: https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Linux

I do not have admin rights to the server, so I am wondering if this means I need to ask admin to install V8?
If so, which version - the brew version? (Im not very linux literate).

Any help very much appreciated.

Here is the error:
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find the libv8 engine library. Try installing:

  • deb: libv8-dev or libnode-dev (Debian / Ubuntu)
  • rpm: v8-devel (Fedora, EPEL)
  • brew: v8 (OSX)
  • csw: libv8_dev (Solaris)
    To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars=β€˜INCLUDE_DIR=… LIB_DIR=…’
    ---------------------------[ ERROR MESSAGE ]----------------------------
    :1:10: fatal error: v8.h: No such file or directory
    compilation terminated.

ERROR: configuration failed for package β€˜V8’

  • removing β€˜/home/jjannot/R/x86_64-pc-linux-gnu-library/4.0/V8’
    ERROR: dependency β€˜V8’ is not available for package β€˜rstan’
  • removing β€˜/home/jjannot/R/x86_64-pc-linux-gnu-library/4.0/rstan’

The downloaded source packages are in
β€˜/tmp/RtmpsiiC9D/downloaded_packages’
Warning messages:
1: In install.packages(β€œrstan”, type = β€œsource”) :
installation of package β€˜V8’ had non-zero exit status
2: In install.packages(β€œrstan”, type = β€œsource”) :
installation of package β€˜rstan’ had non-zero exit status

The details/specs:

  • Operating System - CentOS 7
  • RStan Version - 2.21
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
    CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
    CXX14=/usr/bin/g++

CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=/opt/rh/devtoolset-7/root/usr/bin/g++

CXX14FLAGS=-O3 -march=native -mtune=native -fPIC
CXX14=g++

  • Output of devtools::session_info("rstan")─ Session info ───────────────────────────────────────────────────────────────
    setting value
    version R version 4.0.1 (2020-06-06)
    os CentOS Linux 7 (Core)
    system x86_64, linux-gnu
    ui X11
    language (EN)
    collate en_US.UTF-8
    ctype en_US.UTF-8
    tz America/Los_Angeles
    date 2020-09-01

─ Packages ───────────────────────────────────────────────────────────────────
! package * version date lib source
R rstan [?]

[1] /home/jjannot/R/x86_64-pc-linux-gnu-library/4.0
[2] /opt/R/64-bit/R-4.0.1/lib64/R/library

R ── Package was removed from disk.

I think just install the appropriate package here:

deb: libv8-dev or libnode-dev (Debian / Ubuntu)
rpm: v8-devel (Fedora, EPEL)
brew: v8 (OSX)
csw: libv8_dev (Solaris)

A question like this came up the other day and this seemed to work out there (Rstan no longer working)

If you just need to run Stan models, you might try https://mc-stan.org/cmdstanr/ (it’s probably easier to install)

Thanks for this suggestion.

CmdStanR did install properly. I will now test to see if it plays nice with the custom R functions my collaborator built.

Thank you!

Probably not – the interface changes haha. But if all you’re doing is running models and processing the samples after you’re done, it should be possible to re-engineer code to use it instead of Rstan.

Yeah, that was my fear.

Haha, yeah, I guess give v8 a shot and see if it solves things. Just send that list of packages to your sysadmin and they can probably figure out what to do.

That’s the problem - I asked system admin and they told me to run
scl enable devtoolset-8 bash or
scl enable devtoolset-9 bash

and I quote β€œThose are the latest versions I can supply.”

Neither worked.

But I do appreciate your help! I need to put some pressure on system admin now…

It isn’t the bash or compiler versions. It is having the V8 headers and shared library as indicated by the message

Thanks for this - I didnt know which V8 applied to CentOS 7 - so this is helpful. The problem now is convincing system admin to add that library.

OK it finally worked. For completeness, I include the full solution here in case it can help someone else.

On CentOS 7:
In Linux, I:
installed V8 headers and shared library from here: https://pkgs.org/download/v8-devel (EPEL_x86_64)
bumped gcc from version 4 to 9.3.1
In R:
removed rstan and StanHeaders
installed in a fresh R session

Hope this helps others. Thanks for all the help from everyone here.

1 Like