Installing Old Version of Rstan Problem

Since the current version of rstan (2.18.2) does not produce meaningful error messages if there is an initialization failure (https://github.com/stan-dev/rstan/issues/577) and also swallows all print messages (https://github.com/stan-dev/stan/issues/2737) when using optimizing, I tried to install an older version of stan for debugging a model. I remember that both these things worked at some point.

However, when doing
install_version('rstan','2.15.1',repos='https://www.freestatistics.org/cran/')

I get the errors message

Downloading package from url: https://www.freestatistics.org/cran//src/contrib/Archive/rstan/rstan_2.15.1.tar.gz
Installing rstan
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/lw/kj89878x7ync198n0rbgtc6hgk_515/T/Rtmp4phKG2/devtools3d257e5d29df/rstan'  \
  --library='/Library/Frameworks/R.framework/Versions/3.5/Resources/library' --install-tests 

* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** libs
clang++ -arch x86_64 -ftemplate-depth-256 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"`"/Library/Frameworks/R.framework/Resources/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DFUSION_MAX_VECTOR_SIZE=12 -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include" -I/usr/local/include   -fPIC  -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -c chains.cpp -o chains.o
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:2:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/LU:47:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:3:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Cholesky:12:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Jacobi:29:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:3:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Cholesky:43:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/QR:17:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Householder:27:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/SVD:48:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:6:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Geometry:58:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/mean.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Dense:7:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/Eigenvalues:58:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from chains.cpp:26:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/accumulators/statistics/stats.hpp:14:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/accumulators/statistics_fwd.hpp:12:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/mpl/print.hpp:52:19: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
    const int m_x = 1 / (sizeof(T) - sizeof(T));
                  ^
In file included from chains.cpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/lexical_cast.hpp:31:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/lexical_cast/bad_lexical_cast.hpp:28:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/throw_exception.hpp:70:29: error: no member named 'enable_both' in namespace 'boost::exception_detail'
    throw exception_detail::enable_both( e );
          ~~~~~~~~~~~~~~~~~~^
In file included from chains.cpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/lexical_cast.hpp:32:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:52:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/container/container_fwd.hpp:61:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/container/detail/std_fwd.hpp:27:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
BOOST_MOVE_STD_NS_BEG
^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/move/detail/std_ns_begin.hpp:18:34: note: expanded from macro 'BOOST_MOVE_STD_NS_BEG'
   #define BOOST_MOVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD
                                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__config:390:52: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_STD'
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
                                                   ^
In file included from chains.cpp:29:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/random/additive_combine.hpp:27:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/random/linear_congruential.hpp:30:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/random/detail/const_mod.hpp:23:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/random/detail/large_arithmetic.hpp:19:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/random/detail/integer_log2.hpp:19:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/pending/integer_log2.hpp:7:1: warning: This header is deprecated. Use <boost/integer/integer_log2.hpp> instead. [-W#pragma-messages]
BOOST_HEADER_DEPRECATED("<boost/integer/integer_log2.hpp>");
^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/header_deprecated.hpp:23:37: note: expanded from macro 'BOOST_HEADER_DEPRECATED'
# define BOOST_HEADER_DEPRECATED(a) BOOST_PRAGMA_MESSAGE("This header is deprecated. Use " a " instead.")
                                    ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/config/pragma_message.hpp:24:34: note: expanded from macro 'BOOST_PRAGMA_MESSAGE'
# define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
                                 ^
<scratch space>:130:2: note: expanded from here
 message("This header is deprecated. Use " "<boost/integer/integer_log2.hpp>" " instead.")
 ^
11 warnings and 1 error generated.
make: *** [chains.o] Error 1
ERROR: compilation failed for package ‘rstan’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rstan’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rstan’
Installation failed: Command failed (1)

The error I find is
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/BH/include/boost/throw_exception.hpp:70:29: error: no member named 'enable_both' in namespace 'boost::exception_detail' throw exception_detail::enable_both( e );

I understand that this seems to be related to the headers in the BH package but have no clue how to solve this.

  • Operating System
    Mac 10.12.6

  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))

CXXFLAGS= -Wno-unused-variable -Wno-unused-function  -Wno-macro-redefined -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION

CC=clang
CXX=clang++ -arch x86_64 -ftemplate-depth-256
  • Output of devtools::session_info("rstan")
 package      * version   date       source         
 assertthat     0.2.1     2019-03-21 cran (@0.2.1)  
 backports      1.1.3     2018-12-14 cran (@1.1.3)  
 BH             1.69.0-1  2019-01-07 cran (@1.69.0-)
 callr          3.2.0     2019-03-15 cran (@3.2.0)  
 checkmate      1.9.1     2019-01-15 cran (@1.9.1)  
 cli            1.1.0     2019-03-19 cran (@1.1.0)  
 colorspace     1.3-2     2016-12-14 CRAN (R 3.5.0) 
 compiler       3.5.0     2018-04-24 local          
 crayon         1.3.4     2017-09-16 CRAN (R 3.5.0) 
 desc           1.2.0     2018-05-01 CRAN (R 3.5.0) 
 digest         0.6.18    2018-10-10 cran (@0.6.18) 
 fansi          0.4.0     2018-10-05 cran (@0.4.0)  
 ggplot2      * 3.1.1     2019-04-07 cran (@3.1.1)  
 glue           1.2.0     2017-10-29 CRAN (R 3.5.0) 
 graphics     * 3.5.0     2018-04-24 local          
 grDevices    * 3.5.0     2018-04-24 local          
 grid           3.5.0     2018-04-24 local          
 gridExtra      2.3       2017-09-09 CRAN (R 3.5.0) 
 gtable         0.3.0     2019-03-25 cran (@0.3.0)  
 inline         0.3.15    2018-05-18 CRAN (R 3.5.0) 
 labeling       0.3       2014-08-23 CRAN (R 3.5.0) 
 lattice        0.20-35   2017-03-25 CRAN (R 3.5.0) 
 lazyeval       0.2.2     2019-03-15 cran (@0.2.2)  
 loo            2.1.0     2019-03-13 cran (@2.1.0)  
 magrittr       1.5       2014-11-22 CRAN (R 3.5.0) 
 MASS           7.3-51.4  2019-03-31 CRAN (R 3.5.2) 
 Matrix         1.2-14    2018-04-13 CRAN (R 3.5.0) 
 matrixStats    0.54.0    2018-07-23 CRAN (R 3.5.0) 
 methods      * 3.5.0     2018-04-24 local          
 mgcv           1.8-23    2018-01-21 CRAN (R 3.5.0) 
 munsell        0.5.0     2018-06-12 CRAN (R 3.5.0) 
 nlme           3.1-137   2018-04-07 CRAN (R 3.5.0) 
 parallel       3.5.0     2018-04-24 local          
 pillar         1.3.1     2018-12-15 cran (@1.3.1)  
 pkgbuild       1.0.3     2019-03-20 cran (@1.0.3)  
 pkgconfig      2.0.2     2018-08-16 cran (@2.0.2)  
 plyr           1.8.4     2016-06-08 CRAN (R 3.5.0) 
 prettyunits    1.0.2     2015-07-13 CRAN (R 3.5.0) 
 processx       3.3.0     2019-03-10 cran (@3.3.0)  
 ps             1.3.0     2018-12-21 cran (@1.3.0)  
 R6             2.4.0     2019-02-14 cran (@2.4.0)  
 RColorBrewer   1.1-2     2014-12-07 CRAN (R 3.5.0) 
 Rcpp           1.0.1     2019-03-17 cran (@1.0.1)  
 RcppEigen      0.3.3.5.0 2018-11-24 cran (@0.3.3.5)
 reshape2       1.4.3     2017-12-11 CRAN (R 3.5.0) 
 rlang          0.3.4     2019-04-07 cran (@0.3.4)  
 rprojroot      1.3-2     2018-01-03 CRAN (R 3.5.0) 
 rstan        * 2.18.2    2018-11-07 CRAN (R 3.5.0) 
 scales         1.0.0     2018-08-09 cran (@1.0.0)  
 StanHeaders  * 2.18.1    2019-01-28 cran (@2.18.1) 
 stats        * 3.5.0     2018-04-24 local          
 stats4         3.5.0     2018-04-24 local          
 stringi        1.2.3     2018-06-12 CRAN (R 3.5.0) 
 stringr        1.3.1     2018-05-10 CRAN (R 3.5.0) 
 tibble         2.1.1     2019-03-16 cran (@2.1.1)  
 tools          3.5.0     2018-04-24 local          
 utf8           1.1.4     2018-05-24 CRAN (R 3.5.0) 
 utils        * 3.5.0     2018-04-24 local          
 viridisLite    0.3.0     2018-02-01 CRAN (R 3.5.0) 
 withr          2.1.2     2018-03-15 CRAN (R 3.5.0) 

I had to install rstan 2.17.2 on a cluster I use because the more recent versions weren’t playing well with its Intel compilers. At a minimum, you need to install a matching version of the StanHeaders package; an earlier rstantools may be required as well. You should be able to see the exact requirements by opening the DESCRIPTION file of the rstan version.

Thanks that was the solution. I installed the appropriate version of StanHeaders and BH. After that installation of rstan worked.