Rstan error in RStudio - "Cannot allocate memory of 16921.6 GB"

All I’m using a Windows 10 System (64bit), R 3.6.1 (both 64bit and 32bit), R-Studio 1.1.456 (part of Anaconda3 64bit under Python 3.7.1)

I was checking the installation and execution of rstan 2.19.2 under Cran R and RStudio R (both on 3.6.1)
The following syntax to illustrate a simple Bi-variate Linear Regression) ran correctly on Cran R: (in both cases the R script and the Stan model are in the same working directory)

**Code Starts

stan_bvr <- read.csv(“stan_simple.csv”, sep=",", header = T)

head(stan_bvr)

frmod <- lm(salessh ~ mktgsov, data=stan_bvr)

summary(frmod)

plot(salessh ~ mktgsov, data = stan_bvr)

x <- stan_bvr$mktgsov
y <- stan_bvr$salessh
N <- length(stan_bvr$mktgsov)

lm_alpha <- summary(frmod)$coeff[1] # the intercept
lm_beta <- summary(frmod)$coeff[2] # the slope
lm_sigma <- sigma(frmod) # the residual error

#preparing data for Stan
stan_data = list(N=N, x=x, y=y)

library(rstan)
library(bayesplot)

fit <- stan(file = ‘stan_model1.stan’, data = stan_data, warmup = 500, iter = 1000, chains = 2, cores = 2, thin = 1)

**Code Ends

On RStudio, I began by checking that RTools is being recognized thus:

**Code Starts

library(devtools)
find_rtools() # the result is TRUE

# I repeat the rest of the code. After the “fit” statement I got this error:

Error: cannot allocate vector of size 16921.6 Gb

**Code related stuff ends

I checked the forums here and one user Deleted the Rcpp library and reinstalled it. I did the same and also upgraded from 1.0.2 to 1.0.3.
Tried a few times and no luck.

Then I installed RBuildTools from RStudio (when I temporarily made the original RTools3.5 unavailable. Still the error persisted.

Then I completely uninstalled RStudio and reinstalled into a fresh environment, the error persists. This error has consumed 24 hours over 2 days, when I decided to turn to help here.

What I have not done yet:

  1. Set the Cran R as the RStudio engine and test the rstan example
  2. Anaconda also has Mingw_64 with gcc being a 5.3.0 (RTools Mingw_64 has 4.9.3) - If this crazy error is due to that mis-match I do not know
  3. Play Dark Side of the Moon backwards and see if the solution intelligently emerges

Anyway, thanks for taking the time to give my rant a read. I love the chaos that is the Stan ecosystem. If you have any ideas on what might help and what I missed, I shall pass the gratitude forward

Sree

Try first reinstalling Rcpp from source with the same compiler settings.

Thanks for the quick reply - I’ve removed Rcpp, RcppEigen and rstan and installing together again from source as you advised in another thread. I will let you know how that goes.

Rcpp and RcppEigen install correctly when type=“source” but rstan fails. “Rstan” binary installs correctly. Here is my R Output

> install.packages(“rstan”, type=“source”)
Installing package into ‘C:/Users/DattaS/R/R-library’
(as ‘lib’ is unspecified)
trying URL ‘http://cran.cnr.berkeley.edu/src/contrib/rstan_2.19.2.tar.gz
Content type ‘application/x-gzip’ length 909934 bytes (888 KB)
downloaded 888 KB

** installing source package ‘rstan’ …*
*** package ‘rstan’ successfully unpacked and MD5 sums checked*
*** using staged installation*
*** libs*

**** arch - i386*

g++ -m32 -std=c++1y -I"C:/Users/DattaS/R/R-36~1.1/include" -DNDEBUG -I"…/inst/include" -I"." -I"C:/Users/DattaS/R/R-library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Users/DattaS/R/R-library/Rcpp/include" -I"C:/Users/DattaS/R/R-library/RcppEigen/include" -I"C:/Users/DattaS/R/R-library/BH/include" -I"C:/Users/DattaS/R/R-library/StanHeaders/include" -O3 -c sparse_extractors.cpp -o sparse_extractors.o
In file included from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/random:49:0,

  •             from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/stl_algo.h:66,*
    
  •             from C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/algorithm:62,*
    
  •             from C:/Users/DattaS/R/R-library/RcppEigen/include/Eigen/Core:288,*
    
  •             from C:/Users/DattaS/R/R-library/RcppEigen/include/Eigen/Dense:1,*
    
  •             from C:/Users/DattaS/R/R-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,*
    
  •             from C:/Users/DattaS/R/R-library/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:5,*
    
  •             from sparse_extractors.cpp:2:*
    

C:/Rtools/mingw_64/x86_64-w64-mingw32/include/c++/bits/random.h:106:26: error: expected unqualified-id before ‘__int128’

  •   { typedef unsigned __int128 type; };*
    
  •                      ^*
    

make: *** [C:/Users/DattaS/R/R-36~1.1/etc/i386/Makeconf:215: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’
** removing ‘C:/Users/DattaS/R/R-library/rstan’*

The downloaded source packages are in

  •    ‘C:\Users\DattaS\AppData\Local\Temp\1\RtmpmmdBeP\downloaded_packages’*
    

Warning message:
In install.packages(“rstan”, type = “source”) :

  • installation of package ‘rstan’ had non-zero exit status*

@bgoodri Why is the source version of rstan failing? Error seems to originate at sparse_extractors.cpp

@bgoodri Here is the output when I tried to install rstan 2.19.2 via RStudio

install.packages(“rstan”, type=“source”, dependencies = TRUE)
Installing package into ‘C:/Users/DattaS/R/R-Library’
(as ‘lib’ is unspecified)
trying URL ‘http://cran.cnr.berkeley.edu/src/contrib/rstan_2.19.2.tar.gz
Content type ‘application/x-gzip’ length 909934 bytes (888 KB)
downloaded 888 KB

** installing source package ‘rstan’ …*
*** package ‘rstan’ successfully unpacked and MD5 sums checked*
*** using staged installation*
*** libs*
bash.exe: warning: could not find /tmp, please create!

C:/RTools/mingw_64/bing++ -m64 -std=c++1y" -I"C:/Users/DattaS/AppData/Local/CONTIN~1/ANACON~1/envs/bayesp/lib/R/include" -DNDEBUG -I"…/inst/include" -I"." -I"C:/Users/DattaS/R/R-Library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Users/DattaS/R/R-Library/Rcpp/include" -I"C:/Users/DattaS/R/R-Library/RcppEigen/include" -I"C:/Users/DattaS/R/R-Library/BH/include" -I"C:/Users/DattaS/R/R-Library/StanHeaders/include" -I"C:/Users/DattaS/AppData/Local/CONTIN~1/ANACON~1/envs/bayesp/lib/R/…/…/Library/mingw-w64/include" -O3 -march=native -c sparse_extractors.cpp -o sparse_extractors.o
bash.exe: warning: could not find /tmp, please create!
/usr/bin/sh: -c: line 0: unexpected EOF while looking for matching `"’
/usr/bin/sh: -c: line 1: syntax error: unexpected end of file
make: *** [C:/Users/DattaS/AppData/Local/CONTIN~1/ANACON~1/envs/bayesp/lib/R/etc/x64/Makeconf:216: sparse_extractors.o] Error 1
ERROR: compilation failed for package ‘rstan’
** removing ‘C:/Users/DattaS/R/R-Library/rstan’*
Warning in install.packages :

  • installation of package ‘rstan’ had non-zero exit status*

I’m not sure where that is coming from. This Anaconda thing works differently from a regular R installation and usually worse. Also, there should be another slash in C:/RTools/mingw_64/bing++ so that it is C:/RTools/mingw_64/bin/g++.

Thanks @bgoodri - I will check today and let you know - I was reading elsewhere post by @andrewgelman where he recommended have a trouble shooting page. I work in Windows platform and I can help by contributing to such a section here which documents the basic to the complex issues that people run into for working with . I know it cannot be exhaustive but some times the errors are the same with different shades. If there is any one doing some thing like this, please point me in the right direction.

My sincere appreciation and thanks for the time and effort all the Stan team members and other contributors here and elsewhere put into this.

Sree

@bgoodri I was able to change the nature of the error by correcting the lack of “/” between “bin” and “g++” as you had pointed out.
I removed the binary version of “rstan” and tried to install from source, following the implementation recommended by @paul.buerkner of specifying “no multi-arch”. However as you can see from below, “BH” and “StanHeaders” libraries are throwing exceptions. See my output below: (My Rtools is working correctly since I could compile and install BH and StanHeaders from source)

install.packages(“rstan”, type = “source”, INSTALL_opts = “–no-multiarch”)
Installing package into ‘C:/Users/DattaS/R/R-Library’
(as ‘lib’ is unspecified)
trying URL ‘http://cran.cnr.berkeley.edu/src/contrib/rstan_2.19.2.tar.gz
Content type ‘application/x-gzip’ length 909934 bytes (888 KB)
downloaded 888 KB

  • installing source package ‘rstan’ …
    ** package ‘rstan’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs

C:\Rtools\mingw_64\bin\g++ -O2 -march=native -mtune=native -I"C:/Users/DattaS/R/R-36~1.1/include" -DNDEBUG -I"…/inst/include" -I"." -I"C:/Users/DattaS/R/R-Library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Users/DattaS/R/R-Library/Rcpp/include" -I"C:/Users/DattaS/R/R-Library/RcppEigen/include" -I"C:/Users/DattaS/R/R-Library/BH/include" -I"C:/Users/DattaS/R/R-Library/StanHeaders/include" -O3 -march=native -mtune=native -c sparse_extractors.cpp -o sparse_extractors.o

C:\Rtools\mingw_64\bin\g++ -O2 -march=native -mtune=native -I"C:/Users/DattaS/R/R-36~1.1/include" -DNDEBUG -I"…/inst/include" -I"." -I"C:/Users/DattaS/R/R-Library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Users/DattaS/R/R-Library/Rcpp/include" -I"C:/Users/DattaS/R/R-Library/RcppEigen/include" -I"C:/Users/DattaS/R/R-Library/BH/include" -I"C:/Users/DattaS/R/R-Library/StanHeaders/include" -O3 -march=native -mtune=native -c misc.cpp -o misc.o

C:\Rtools\mingw_64\bin\g++ -O2 -march=native -mtune=native -I"C:/Users/DattaS/R/R-36~1.1/include" -DNDEBUG -I"…/inst/include" -I"." -I"C:/Users/DattaS/R/R-Library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -I"C:/Users/DattaS/R/R-Library/Rcpp/include" -I"C:/Users/DattaS/R/R-Library/RcppEigen/include" -I"C:/Users/DattaS/R/R-Library/BH/include" -I"C:/Users/DattaS/R/R-Library/StanHeaders/include" -O3 -march=native -mtune=native -c stanc.cpp -o stanc.o
In file included from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/include/phoenix_limits.hpp:11:0,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/home/support/meta_compiler.hpp:16,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/home/qi/meta_compiler.hpp:14,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/home/qi/action/action.hpp:14,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/home/qi/action.hpp:14,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/home/qi.hpp:14,
from C:/Users/DattaS/R/R-Library/BH/include/boost/spirit/include/qi.hpp:16,
from ./stan/lang/grammars/whitespace_grammar.hpp:4,
from ./stan/lang/grammars/program_grammar.hpp:6,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/parser.hpp:5,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:7,
from stanc.cpp:22:
C:/Users/DattaS/R/R-Library/BH/include/boost/phoenix/core/limits.hpp:44:0: warning: “BOOST_PHOENIX_NO_VARIADIC_EXPRESSION” redefined

define BOOST_PHOENIX_NO_VARIADIC_EXPRESSION

^
:0:0: note: this is the location of the previous definition
In file included from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/ast/type/block_array_type.hpp:5:0,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/ast.hpp:11,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:5,
from stanc.cpp:22:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/ast/type/block_var_type.hpp:54:48: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::recursive_wrapper<block_array_type>>
^
In file included from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_constructor.hpp:11:0,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator.hpp:43,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:6,
from stanc.cpp:22:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_set_param_ranges.hpp: In function ‘void stan::lang::generate_set_param_ranges(const std::vectorstan::lang::block_var_decl&, int, std::ostream&)’:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_set_param_ranges.hpp:53:39: warning: name lookup of ‘i’ changed
generate_expression(var_decls[i].type().params_total(),
^
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_set_param_ranges.hpp:36:19: warning: matches this ‘i’ under ISO standard rules
for (size_t i = 0; i < var_decls.size(); ++i) {
^
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_set_param_ranges.hpp:48:21: warning: matches this ‘i’ under old rules
for (size_t i = 0; i < ar_lens.size(); ++i)
^
In file included from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_cpp.hpp:26:0,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator.hpp:44,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:6,
from stanc.cpp:22:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp: In function ‘void stan::lang::generate_register_mpi(const string&, std::ostream&)’:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:15:13: error: ‘a’ does not name a type
for (auto a : map_rect::registered_calls()) {
^
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected ‘;’ before ‘}’ token
}
^
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected primary-expression before ‘}’ token
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected ‘;’ before ‘}’ token
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected primary-expression before ‘}’ token
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected ‘)’ before ‘}’ token
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_register_mpi.hpp:22:1: error: expected primary-expression before ‘}’ token
In file included from ./stan/lang/grammars/expression07_grammar.hpp:8:0,
from ./stan/lang/grammars/expression_grammar.hpp:5,
from ./stan/lang/grammars/program_grammar.hpp:7,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/parser.hpp:5,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:7,
from stanc.cpp:22:
./stan/lang/grammars/semantic_actions.hpp: At global scope:
./stan/lang/grammars/semantic_actions.hpp:26:61: error: ‘>>’ should be ‘> >’ within a nested template argument list
int num_dimss(std::vector<std::vectorstan::lang::expression> &dimss);
^
./stan/lang/grammars/semantic_actions.hpp:256:66: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::set<std::pair<std::string, function_signature_t>> &declared,
^
./stan/lang/grammars/semantic_actions.hpp:257:66: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::set<std::pair<std::string, function_signature_t>> &defined,
^
./stan/lang/grammars/semantic_actions.hpp:266:59: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::set<std::pair<std::string, function_signature_t>>
^
./stan/lang/grammars/semantic_actions.hpp:268:59: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::set<std::pair<std::string, function_signature_t>> &functions_defined,
^
./stan/lang/grammars/semantic_actions.hpp:748:65: error: ‘>>’ should be ‘> >’ within a nested template argument list
std::vector<std::vectorstan::lang::expression> &dimss,
^
In file included from ./stan/lang/grammars/program_grammar.hpp:8:0,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/parser.hpp:5,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compiler.hpp:7,
from stanc.cpp:22:
./stan/lang/grammars/block_var_decls_grammar.hpp:22:61: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar> {
^
./stan/lang/grammars/block_var_decls_grammar.hpp:30:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:34:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:38:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:42:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:46:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:50:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:54:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:58:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:62:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:66:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:70:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:74:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:78:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:82:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:86:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:90:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:94:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:98:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:102:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:106:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:110:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:114:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:117:79: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::spirit::qi::rule<Iterator, std::string(), whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:120:79: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::spirit::qi::rule<Iterator, std::string(), whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:124:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:128:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:131:78: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::spirit::qi::rule<Iterator, range(scope), whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:134:78: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::spirit::qi::rule<Iterator, range(scope), whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:138:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:142:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:145:78: error: ‘>>’ should be ‘> >’ within a nested template argument list
boost::spirit::qi::rule<Iterator, range(scope), whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:149:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:153:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
./stan/lang/grammars/block_var_decls_grammar.hpp:157:54: error: ‘>>’ should be ‘> >’ within a nested template argument list
whitespace_grammar>
^
In file included from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_function_instantiation.hpp:6:0,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_function_instantiations.hpp:5,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_standalone_functions.hpp:7,
from C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/compile_functions.hpp:4,
from stanc.cpp:23:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_function_instantiation_body.hpp: In function ‘void stan::lang::generate_function_instantiation_body(const stan::lang::function_decl_def&, const std::vector<std::basic_string >&, bool, bool, bool, const string&, std::ostream&)’:
C:/Users/DattaS/R/R-Library/StanHeaders/include/src/stan/lang/generator/generate_function_instantiation_body.hpp:44:45: error: range-based ‘for’ loops are not allowed in C++98 mode
for (const std::string& namespace_i : namespaces) {
^
make: *** [C:/Users/DattaS/R/R-36~1.1/etc/x64/Makeconf:216: stanc.o] Error 1
ERROR: compilation failed for package ‘rstan’

  • removing ‘C:/Users/DattaS/R/R-Library/rstan’

The downloaded source packages are in
‘C:\Users\DattaS\AppData\Local\Temp\2\RtmpIfjJ7H\downloaded_packages’
Warning message:
In install.packages(“rstan”, type = “source”, INSTALL_opts = “–no-multiarch”) :
installation of package ‘rstan’ had non-zero exit status

This is due to the lack of -std=c++1y in CXX14FLAGS in ~/.R/Makevars.win .

@bgoodri - Ben, thank you so much; that tweak worked. Of what help it might be I’m going to post a note on how I made RStan work in Cran R and R-Studio R either today or tomorrow once I gather all of my notes together on what I tried to do and what worked.

One additional note is that I have been using the “Makeconf” in R-3.6.1\etc\X64\ location and specifying my CXX14 and CXX11 flags / parameters. It has been working without utilizing .R/Makevars

What you caught in the output “bing++” where it should be “bin\g++” is potentially a bug in R-3.6.1 Makeconf file. In previous R versions I would only specify Rtools location as C:/Rtools/bin and C:/Rtools/mingw_64/bin and R would automatically insert the “/” character. But now that is not working in 3.6.1 version of R

One more point that @paul.buerkner identified through “No Multiarch” is working for me only if I comment out the BINPREF variable in the 32-bit version of Makeconf file (R-3.6.1/etc/i386/). My path only has Rtools/bin and Rtools/mingw_64/bin. However, when compiling anything from source R was looking for the Rtools/mingw_32/bin. I realized that this is happening since I’m on a work laptop where I do not have admin rights and there is a Rtools33/mingw_32/bin (on the main System PATH after Rtools33/bin and Rtools/mingw_32/bin) that I cannot change.

So to bypass that I have modified my .Rprofile file so that Sys.setenv(“PATH”) is set to what I need to use. I will pull these together into a separate post and post it here in the forum.

Thank you once again for helping me catch up on sleep

Sree