Error in stan installation: "rscript execution error: No such file or directory installing packages"

Hi all, I’m having some difficulty installing Rstan to use on a HPC cluster. I have read a few similar posts from others on this page but nothing has worked so far. I’m struggling to install the ‘RccpParallel’ and ‘StanHeaders’ packages which are dependencies for rstan.

I first use

module add R

to loads R version 4.0.2 and gcc 8.2.0.

After doing

install.packages("rstan", dependencies = TRUE)

I get the following warnings:

1: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘RcppParallel’ had non-zero exit status
2: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘V8’ had non-zero exit status
3: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘StanHeaders’ had non-zero exit status
4: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘rstantools’ had non-zero exit status
5: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘rstan’ had non-zero exit status
6: In install.packages("rstan", dependencies = TRUE) :
  installation of package ‘shinystan’ had non-zero exit status

If I focus on installing RcppParallel for instance, I get the following error:

> install.packages("RcppParallel", dependencies = TRUE)
Installing package into ‘/mnt/cephfs/ceph01/site-home/home/d420/d420/ryanchan/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.ma.imperial.ac.uk/src/contrib/RcppParallel_5.1.5.tar.gz'
Content type 'application/x-gzip' length 1967672 bytes (1.9 MB)
==================================================
downloaded 1.9 MB

* installing *source* package ‘RcppParallel’ ...
** package ‘RcppParallel’ successfully unpacked and MD5 sums checked
** using staged installation
Rscript execution error: No such file or directory
ERROR: configuration failed for package ‘RcppParallel’
* removing ‘/mnt/cephfs/ceph01/site-home/home/d420/d420/ryanchan/R/x86_64-pc-linux-gnu-library/4.0/RcppParallel’

The downloaded source packages are in
	‘/tmp/RtmpzsTS6o/downloaded_packages’
Warning message:
In install.packages("RcppParallel", dependencies = TRUE) :
  installation of package ‘RcppParallel’ had non-zero exit status

I’m not sure why I’m getting the Rscript execution error: No such file or directory error here. If I type

which Rscript

in the terminal, I get

/scratch/sw/R/4.0.2/bin/Rscript

and Rscript works as a command here too.

[ryanchan@cirrus-login2 ~]$ Rscript
Usage: /path/to/Rscript [--options] [-e expr [-e expr2 ...] | file] [args]

--options accepted are
  --help              Print usage and exit
  --version           Print version and exit
  --verbose           Print information on progress
  --default-packages=list
                      Where 'list' is a comma-separated set
                        of package names, or 'NULL'
or options to R, in addition to --no-echo --no-restore, such as
  --save              Do save workspace at the end of the session
  --no-environ        Don't read the site and user environment files
  --no-site-file      Don't read the site-wide Rprofile
  --no-init-file      Don't read the user R profile
  --restore           Do restore previously saved objects at startup
  --vanilla           Combine --no-save, --no-restore, --no-site-file
                        --no-init-file and --no-environ

'file' may contain spaces but not shell metacharacters
Expressions (one or more '-e <expr>') may be used *instead* of 'file'
See also  ?Rscript  from within R

If I look at the errors for installing V8 I have:

* installing *source* package ‘V8’ ...
** package ‘V8’ successfully unpacked and MD5 sums checked
** using staged installation
Found C++17 compiler: g++
Rscript execution error: No such file or directory
Unexpected architecture:
Using CXXCPP=g++ -std=gnu++17 -E
Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
Using PKG_LIBS=-lv8 -lv8_libplatform
-----------------------------[ 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)
Alternatively, on Linux (x86_64) or MacOS you can set environment variable:
    DOWNLOAD_STATIC_LIBV8=1
to automatically download a static version of libv8.
To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
---------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:10: fatal error: v8.h: No such file or directory
compilation terminated.
------------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/mnt/cephfs/ceph01/site-home/home/d420/d420/ryanchan/R/x86_64-pc-linux-gnu-library/4.0/V8’

The downloaded source packages are in
	‘/tmp/RtmpRKxJCn/downloaded_packages’
Warning message:
In install.packages("V8") :
  installation of package ‘V8’ had non-zero exit status

Anyone have similar problems or know what to do here? Apologies if this is not enough information, I can provide more details if needed.

Ryan, I am no expert here but could say something about the V8 error message. The “ANTICONF” part suggests that you need to install libv8 on your system, outside of R. I am not sure how you would do that on a cluster, it seems that more information about your cluster would be needed.

I think that rstan installation fails because it requires V8, and V8 could not be installed. I am not sure about the RcppParallel thing, but it might also need something extra to be installed outside of R.

I have a question (not sure if this is the right place to post but the topic seems related). After installing RStan I tried to verify my installation by running:

example(stan_model, package = “rstan”, run.dontrun = TRUE)

After doing so I then got this error message:

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_observer_v3D1Ev]+0x14): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:/RBuildTools/4.0/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/8.3.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: file6834192127b1.o:file6834192127b1.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD0Ev[_ZN3tbb10interface623task_scheduler_observerD0Ev]+0x1c): undefined reference to `tbb::internal::t

So I restarted R and reinstalled RStan and Stan headers by entering:

Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))

install.packages(c(“StanHeaders”,“rstan”),type=“source”)

However, I still get the same error message when I try to verify my RStan installation. What should I do?

I basically followed the steps outlined in: RStan Getting Started · stan-dev/rstan Wiki · GitHub