Installation issues on RedHat 7

Has anyone had issues with users permissions when installing or running rstan?

I normally install R packages with a standard user but was unable to install it via a standard linux user. So I tried installing with root permissions. This allowed me to install rstan and run the example code.

When I try to run the example using a standard user it gives me the following error.

library(rstan)
example(stan_model,run.dontrun = TRUE)
368:  return Rcpp::wrap("16a540c6086086816528e4524def24d9");
369: }

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
          ^~~/opt/R/4.0.3/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/accumulator.hpp:98:8: note:   template argument deduction/substitution failed:file1e82840495140.cpp:180:9: note:   ‘stan::math::var’ is not derived from ‘const std::vector<T>’         lp_accum__.add(lp__);         ^~~~~~~~~~make: *** [/opt/R/4.0.3/lib/R/etc/Makeconf:183: file1e82840495140.o] Error 1

When running the example as root or sudo permissions it completes successfully.

When I try to install via the normal linux user I get the following error. However it installs fine when installing as root or sudo permissions.

/opt/R/4.0.3/lib/R/library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(4) double’} [-Wignored-attributes]
   enum {
        ^
make: *** [/opt/R/4.0.3/lib/R/etc/Makeconf:183: chains.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/opt/R/4.0.3/lib/R/library/rstan’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rstan", lib = "/opt/R/4.0.3/lib/R/library") :
  installation of package ‘rstan’ had non-zero exit status

The server doesn’t have access external internet so it makes installing a little more complicated but I don’t think this is causing an issue in this case but I am not sure. I am able to install all other standard packages.

I did follow the advice in the following thread and installed devtoolset-8. Previous to this I wasn’t able to get it installed with root or standard linux user. Reinstalling odbc on R 4.0 on Linux RHEL 7 - odbc - RStudio Community

1 Like

Sorry, it seems your question fell through a bit. I am not a Linux person, but tagging @rok_cesnovar who might know more.

Some very general pointers:

  • Can you compile source packages? (e.g. install.packages("jsonlite", type = "source"))
  • Are you able to compile other code via Rcpp/inline ? E.g.,
    fx <- cxxfunction(signature(x = "integer", y = "numeric"), 
                      "return wrap( as<int>(x) * as<double>(y));",
                      plugin = "Rcpp" )
    fx(2L, 5)
  • You can also try using CmdStanR which is still somewhat experimental but tends to be easier to install (and has very good diagnostics to point you to specific issues with your setup).

Best of luck!

Thanks for the tag.

Before trying the general pointers Martin lists, I would check that the gcc/g++ compiler meets the minimum requirements. I suspect this is the issue here as I believe the default RedHat7 g++ is 4.8.x.

Please run

g++ --version

in the terminal and if the reported version is below 4.9.3 you need to upgrade. I would recommend upgrading to at least g++ 8 (most recent version is 10.2).

1 Like

Hi Guys,

I am able to install source packages; however all the packages are managed in an offline setting.

Am able to compile other cpp/inline packages.

> library(inline)

Attaching package: ‘inline’

The following object is masked from ‘package:Rcpp’:

    registerPlugin

> fx <- cxxfunction(signature(x = "integer", y = "numeric"),
+                       "return wrap( as<int>(x) * as<double>(y));",
+                       plugin = "Rcpp" )

>     fx(2L, 5)
[1] 10

Can look into CmdStanR. Is it still the same packages available to the end user?

In terms of g++ I followed the advice on installing devtoolset-8

As long as I run the following it seems to load the latest version. I am able to install it as root user so the versions must be compatible I’m thinking but there must be some issue with permissions somewhere along the line where the standard user can’t access or install some files.

source scl_source enable devtoolset-8
g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 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.

-sh-4.2$ source scl_source enable devtoolset-8
You have new mail in /var/spool/mail/atsprod

-sh-4.2$ g++ --version
g++ (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
Copyright (C) 2018 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.

1 Like

Then it might be a problem with different versions of packages in the admin and non-admin user.

Can you print all the package versions for both and see if there is a difference?

They should be the same version of the package.

rstan_2.21.2.tar.gz

I have this manually downloaded onto the server in order to install it so both users are pointing to the same file. Same commands and config in order to install them.

I can print the package version for installing via root but it fails with the standard user.

> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.7 (Maipo)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

locale:
 [1] LC_CTYPE=en_IE.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_IE.UTF-8        LC_COLLATE=en_IE.UTF-8
 [5] LC_MONETARY=en_IE.UTF-8    LC_MESSAGES=en_IE.UTF-8
 [7] LC_PAPER=en_IE.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_IE.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rstan_2.21.2         ggplot2_3.3.3        StanHeaders_2.21.0-7
[4] inline_0.3.17        Rcpp_1.0.5

loaded via a namespace (and not attached):
 [1] pillar_1.4.7       compiler_4.0.3     prettyunits_1.1.1  tools_4.0.3
 [5] pkgbuild_1.2.0     jsonlite_1.7.2     lifecycle_0.2.0    tibble_3.0.4
 [9] gtable_0.3.0       pkgconfig_2.0.3    rlang_0.4.10       cli_2.2.0
[13] parallel_4.0.3     curl_4.3           loo_2.4.1          gridExtra_2.3
[17] withr_2.3.0        dplyr_1.0.2        generics_0.1.0     vctrs_0.3.6
[21] stats4_4.0.3       grid_4.0.3         tidyselect_1.1.0   glue_1.4.2
[25] R6_2.5.0           processx_3.4.5     fansi_0.4.1        callr_3.5.1
[29] purrr_0.3.4        magrittr_2.0.1     codetools_0.2-16   scales_1.1.1
[33] ps_1.5.0           ellipsis_0.3.1     matrixStats_0.57.0 assertthat_0.2.1
[37] colorspace_2.0-0   V8_3.4.0           RcppParallel_5.0.2 munsell_0.5.0
[41] crayon_1.3.4

Hm, this seems like a more general problem with your R environment. Or is this only with rstan?

Looks like it is only an issue with rstan.

It fails to install with the standard user; as per the second error message in the first post.

/opt/R/4.0.3/lib/R/library/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits<double>::type’ {aka ‘__vector(4) double’} [-Wignored-attributes]
   enum {
        ^
make: *** [/opt/R/4.0.3/lib/R/etc/Makeconf:183: chains.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/opt/R/4.0.3/lib/R/library/rstan’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("rstan", lib = "/opt/R/4.0.3/lib/R/library") :
  installation of package ‘rstan’ had non-zero exit status

All other packages can be installed with no issues. rstan seems to be the only one giving issues.

I usually install all packages with the standard user; not root. But as was failing and I was testing I tried with root and was able to install and run the examples. However none of the standard users are able to run the examples when installed via root.

I’m guessing it is not recommended to install rstan via root? Standard linux users should be sufficient?

Yes, this is a standard recommendation for any package (in R or otherwise).