Trouble with c++ compiler w/brm

I have installed Rtools and set the PATH as instructed ( PATH="{RTOOLS40_HOME}\usr\bin;{PATH}"). I then installed RStan following the instructions. Rtools is recognized by Rstudio and the c++ toolchain seems to be in order (pkgbuild::has_build_tools(debug = TRUE)).

However, when running brm I get the error message below. I know this must be something very simple but I am stumped. Problem with Rtools, or the path? Ideas?
Thanks in advance.

Compiling the C++ model
Error in file(con, "r") : cannot open the connection
In addition: Warning messages:
1: In system(cmd, intern = !verbose) :
  running command 'C:/PROGRA~1/R/R-40~1.1/bin/x64/R CMD SHLIB file2b7c36ebd77.cpp 2> file2b7c36ebd77.cpp.err.txt' had status 1
2: In file(con, "r") :
  cannot open file 'file2b7c36ebd77.cpp.err.txt': No such file or directory
Error in sink(type = "output") : invalid connection
  • Operating System: Windows 10
  • brms Version: brms 2.13.0

Need to see

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

and in particular the section of the output below Compilation argument:.

As requested.

stn_md> stancode <- ‘data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}’

stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘73fc79f8b1915e8208c736914c86d1a1’.
COMPILING THE C++ CODE FOR MODEL ‘73fc79f8b1915e8208c736914c86d1a1’ NOW.
OS: x86_64, mingw32; rstan: 2.19.3; Rcpp: 1.0.4.6; inline: 0.3.15

setting environment variables:
PKG_LIBS = -L"C:/Program Files/R/R-4.0.1/library/StanHeaders/libs/x64" -lStanHeaders
PKG_CPPFLAGS = -I"C:/Program Files/R/R-4.0.1/library/Rcpp/include/" -I"C:/Program Files/R/R-4.0.1/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.1/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.1/library/BH/include" -I"C:/Program Files/R/R-4.0.1/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.1/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.1/library/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y

Program source :

1 :
2 : // includes from the plugin
3 : // [[Rcpp::plugins(cpp14)]]
4 :
5 : // user includes
6 : #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
7 : #include <rstan/rstaninc.hpp>
8 : // Code generated by Stan version 2.21.0
9 :
10 : #include <stan/model/model_header.hpp>
11 :
12 : namespace model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace {
13 :
14 : using std::istream;
15 : using std::string;
16 : using std::stringstream;
17 : using std::vector;
18 : using stan::io::dump;
19 : using stan::math::lgamma;
20 : using stan::model::prob_grad;
21 : using namespace stan::math;
22 :
23 : static int current_statement_begin__;
24 :
25 : stan::io::program_reader prog_reader__() {
26 : stan::io::program_reader reader;
27 : reader.add_event(0, 0, “start”, “model14068453f49_73fc79f8b1915e8208c736914c86d1a1”);
28 : reader.add_event(3, 1, “end”, “model14068453f49_73fc79f8b1915e8208c736914c86d1a1”);
29 : return reader;
30 : }
31 :
32 : class model14068453f49_73fc79f8b1915e8208c736914c86d1a1
33 : : public stan::model::model_base_crtp<model14068453f49_73fc79f8b1915e8208c736914c86d1a1> {
34 : private:
35 : double y_mean;
36 : public:
37 : model14068453f49_73fc79f8b1915e8208c736914c86d1a1(stan::io::var_context& context__,
38 : std::ostream* pstream__ = 0)
39 : : model_base_crtp(0) {
40 : ctor_body(context__, 0, pstream__);
41 : }
42 :
43 : model14068453f49_73fc79f8b1915e8208c736914c86d1a1(stan::io::var_context& context__,
44 : unsigned int random_seed__,
45 : std::ostream* pstream__ = 0)
46 : : model_base_crtp(0) {
47 : ctor_body(context__, random_seed__, pstream__);
48 : }
49 :
50 : void ctor_body(stan::io::var_context& context__,
51 : unsigned int random_seed__,
52 : std::ostream* pstream__) {
53 : typedef double local_scalar_t__;
54 :
55 : boost::ecuyer1988 base_rng__ =
56 : stan::services::util::create_rng(random_seed__, 0);
57 : (void) base_rng__; // suppress unused var warning
58 :
59 : current_statement_begin__ = -1;
60 :
61 : static const char* function__ = “model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1”;
62 : (void) function__; // dummy to suppress unused var warning
63 : size_t pos__;
64 : (void) pos__; // dummy to suppress unused var warning
65 : std::vector vals_i__;
66 : std::vector vals_r__;
67 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
68 : (void) DUMMY_VAR__; // suppress unused var warning
69 :
70 : try {
71 : // initialize data block variables from context__
72 : current_statement_begin__ = 1;
73 : context__.validate_dims(“data initialization”, “y_mean”, “double”, context__.to_vec());
74 : y_mean = double(0);
75 : vals_r__ = context__.vals_r(“y_mean”);
76 : pos__ = 0;
77 : y_mean = vals_r__[pos__++];
78 :
79 :
80 : // initialize transformed data variables
81 : // execute transformed data statements
82 :
83 : // validate transformed data
84 :
85 : // validate, set parameter ranges
86 : num_params_r__ = 0U;
87 : param_ranges_i__.clear();
88 : current_statement_begin__ = 1;
89 : num_params_r__ += 1;
90 : } catch (const std::exception& e) {
91 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
92 : // Next line prevents compiler griping about no return
93 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
94 : }
95 : }
96 :
97 : ~model14068453f49_73fc79f8b1915e8208c736914c86d1a1() { }
98 :
99 :
100 : void transform_inits(const stan::io::var_context& context__,
101 : std::vector& params_i__,
102 : std::vector& params_r__,
103 : std::ostream
pstream__) const {
104 : typedef double local_scalar_t__;
105 : stan::io::writer writer__(params_r__, params_i__);
106 : size_t pos__;
107 : (void) pos__; // dummy call to supress warning
108 : std::vector vals_r__;
109 : std::vector vals_i__;
110 :
111 : current_statement_begin__ = 1;
112 : if (!(context__.contains_r(“y”)))
113 : stan::lang::rethrow_located(std::runtime_error(std::string(“Variable y missing”)), current_statement_begin__, prog_reader__());
114 : vals_r__ = context__.vals_r(“y”);
115 : pos__ = 0U;
116 : context__.validate_dims(“parameter initialization”, “y”, “double”, context__.to_vec());
117 : double y(0);
118 : y = vals_r__[pos__++];
119 : try {
120 : writer__.scalar_unconstrain(y);
121 : } catch (const std::exception& e) {
122 : stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_reader__());
123 : }
124 :
125 : params_r__ = writer__.data_r();
126 : params_i__ = writer__.data_i();
127 : }
128 :
129 : void transform_inits(const stan::io::var_context& context,
130 : Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
131 : std::ostream
pstream__) const {
132 : std::vector params_r_vec;
133 : std::vector params_i_vec;
134 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
135 : params_r.resize(params_r_vec.size());
136 : for (int i = 0; i < params_r.size(); ++i)
137 : params_r(i) = params_r_vec[i];
138 : }
139 :
140 :
141 : template <bool propto__, bool jacobian__, typename T__>
142 : T__ log_prob(std::vector<T__>& params_r__,
143 : std::vector& params_i__,
144 : std::ostream
pstream__ = 0) const {
145 :
146 : typedef T__ local_scalar_t__;
147 :
148 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
149 : (void) DUMMY_VAR__; // dummy to suppress unused var warning
150 :
151 : T__ lp__(0.0);
152 : stan::math::accumulator<T__> lp_accum__;
153 : try {
154 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
155 :
156 : // model parameters
157 : current_statement_begin__ = 1;
158 : local_scalar_t__ y;
159 : (void) y; // dummy to suppress unused var warning
160 : if (jacobian__)
161 : y = in__.scalar_constrain(lp__);
162 : else
163 : y = in__.scalar_constrain();
164 :
165 : // model body
166 :
167 : current_statement_begin__ = 1;
168 : lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
169 :
170 : } catch (const std::exception& e) {
171 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
172 : // Next line prevents compiler griping about no return
173 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
174 : }
175 :
176 : lp_accum__.add(lp__);
177 : return lp_accum__.sum();
178 :
179 : } // log_prob()
180 :
181 : template <bool propto, bool jacobian, typename T_>
182 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
183 : std::ostream
pstream = 0) const {
184 : std::vector<T_> vec_params_r;
185 : vec_params_r.reserve(params_r.size());
186 : for (int i = 0; i < params_r.size(); ++i)
187 : vec_params_r.push_back(params_r(i));
188 : std::vector vec_params_i;
189 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
190 : }
191 :
192 :
193 : void get_param_names(std::vectorstd::string& names__) const {
194 : names__.resize(0);
195 : names__.push_back(“y”);
196 : }
197 :
198 :
199 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
200 : dimss__.resize(0);
201 : std::vector<size_t> dims__;
202 : dims__.resize(0);
203 : dimss__.push_back(dims__);
204 : }
205 :
206 : template
207 : void write_array(RNG& base_rng__,
208 : std::vector& params_r__,
209 : std::vector& params_i__,
210 : std::vector& vars__,
211 : bool include_tparams__ = true,
212 : bool include_gqs__ = true,
213 : std::ostream
pstream__ = 0) const {
214 : typedef double local_scalar_t__;
215 :
216 : vars__.resize(0);
217 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
218 : static const char
function__ = “model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::write_array”;
219 : (void) function__; // dummy to suppress unused var warning
220 :
221 : // read-transform, write parameters
222 : double y = in__.scalar_constrain();
223 : vars__.push_back(y);
224 :
225 : double lp__ = 0.0;
226 : (void) lp__; // dummy to suppress unused var warning
227 : stan::math::accumulator lp_accum__;
228 :
229 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
230 : (void) DUMMY_VAR__; // suppress unused var warning
231 :
232 : if (!include_tparams__ && !include_gqs__) return;
233 :
234 : try {
235 : if (!include_gqs__ && !include_tparams__) return;
236 : if (!include_gqs__) return;
237 : } catch (const std::exception& e) {
238 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
239 : // Next line prevents compiler griping about no return
240 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
241 : }
242 : }
243 :
244 : template
245 : void write_array(RNG& base_rng,
246 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
247 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
248 : bool include_tparams = true,
249 : bool include_gqs = true,
250 : std::ostream
pstream = 0) const {
251 : std::vector params_r_vec(params_r.size());
252 : for (int i = 0; i < params_r.size(); ++i)
253 : params_r_vec[i] = params_r(i);
254 : std::vector vars_vec;
255 : std::vector params_i_vec;
256 : write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
257 : vars.resize(vars_vec.size());
258 : for (int i = 0; i < vars.size(); ++i)
259 : vars(i) = vars_vec[i];
260 : }
261 :
262 : std::string model_name() const {
263 : return “model14068453f49_73fc79f8b1915e8208c736914c86d1a1”;
264 : }
265 :
266 :
267 : void constrained_param_names(std::vectorstd::string& param_names__,
268 : bool include_tparams__ = true,
269 : bool include_gqs__ = true) const {
270 : std::stringstream param_name_stream__;
271 : param_name_stream__.str(std::string());
272 : param_name_stream__ << “y”;
273 : param_names__.push_back(param_name_stream__.str());
274 :
275 : if (!include_gqs__ && !include_tparams__) return;
276 :
277 : if (include_tparams__) {
278 : }
279 :
280 : if (!include_gqs__) return;
281 : }
282 :
283 :
284 : void unconstrained_param_names(std::vectorstd::string& param_names__,
285 : bool include_tparams__ = true,
286 : bool include_gqs__ = true) const {
287 : std::stringstream param_name_stream__;
288 : param_name_stream__.str(std::string());
289 : param_name_stream__ << “y”;
290 : param_names__.push_back(param_name_stream__.str());
291 :
292 : if (!include_gqs__ && !include_tparams__) return;
293 :
294 : if (include_tparams__) {
295 : }
296 :
297 : if (!include_gqs__) return;
298 : }
299 :
300 : }; // model
301 :
302 : } // namespace
303 :
304 : typedef model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1 stan_model;
305 :
306 : #ifndef USING_R
307 :
308 : stan::model::model_base& new_model(
309 : stan::io::var_context& data_context,
310 : unsigned int seed,
311 : std::ostream
msg_stream) {
312 : stan_model
m = new stan_model(data_context, seed, msg_stream);
313 : return m;
314 : }
315 :
316 : #endif
317 :
318 : /
*
319 : * Define Rcpp Module to expose stan_fit’s functions to R.
320 : */
321 : RCPP_MODULE(stan_fit4model14068453f49_73fc79f8b1915e8208c736914c86d1a1_mod){
322 : Rcpp::class_<rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1,
323 : boost::random::ecuyer1988> >(“stan_fit4model14068453f49_73fc79f8b1915e8208c736914c86d1a1”)
324 : // .constructorRcpp::List()
325 : .constructor<SEXP, SEXP, SEXP>()
326 : // .constructor<SEXP, SEXP>()
327 : .method(“call_sampler”,
328 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::call_sampler)
329 : .method(“param_names”,
330 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_names)
331 : .method(“param_names_oi”,
332 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_names_oi)
333 : .method(“param_fnames_oi”,
334 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_fnames_oi)
335 : .method(“param_dims”,
336 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_dims)
337 : .method(“param_dims_oi”,
338 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_dims_oi)
339 : .method(“update_param_oi”,
340 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::update_param_oi)
341 : .method(“param_oi_tidx”,
342 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::param_oi_tidx)
343 : .method(“grad_log_prob”,
344 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::grad_log_prob)
345 : .method(“log_prob”,
346 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::log_prob)
347 : .method(“unconstrain_pars”,
348 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::unconstrain_pars)
349 : .method(“constrain_pars”,
350 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::constrain_pars)
351 : .method(“num_pars_unconstrained”,
352 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::num_pars_unconstrained)
353 : .method(“unconstrained_param_names”,
354 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::unconstrained_param_names)
355 : .method(“constrained_param_names”,
356 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::constrained_param_names)
357 : .method(“standalone_gqs”,
358 : &rstan::stan_fit<model14068453f49_73fc79f8b1915e8208c736914c86d1a1_namespace::model14068453f49_73fc79f8b1915e8208c736914c86d1a1, boost::random::ecuyer1988>::standalone_gqs)
359 : ;
360 : }
361 :
362 : // declarations
363 : extern “C” {
364 : SEXP file1403e5a6b41( ) ;
365 : }
366 :
367 : // definition
368 :
369 : SEXP file1403e5a6b41( ){
370 : return Rcpp::wrap(“73fc79f8b1915e8208c736914c86d1a1”);
371 : }
372 :
373 :
Compilation argument:
C:/PROGRA~1/R/R-40~1.1/bin/x64/R CMD SHLIB file1403e5a6b41.cpp 2> file1403e5a6b41.cpp.err.txt
“C:/rtools40/mingw64/bin/“g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.1/include” -DNDEBUG -I"C:/Program Files/R/R-4.0.1/library/Rcpp/include/” -I"C:/Program Files/R/R-4.0.1/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.1/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.1/library/BH/include" -I"C:/Program Files/R/R-4.0.1/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.1/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.1/library/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp -std=c++1y -march=core2 -include C:/Program Files/R/R-4.0.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp -I “C:/Program Files/R/R-4.0.1/library/StanHeaders/include” -I “C:/Program Files/R/R-4.0.1/library/RcppEigen/include” -O3 -march=native -mtune=native -c file1403e5a6b41.cpp -o file1403e5a6b41.o
g++.exe: error: Files/R/R-4.0.1/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory
make: *** [C:/PROGRA~1/R/R-40~1.1/etc/x64/Makeconf:229: file1403e5a6b41.o] Error 1
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘file1403e5a6b41.cpp.err.txt’: No such file or directory

Is this what you needed?

Yeah, although you probably have to use rstan from GitHub with

remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

Sorry, now I am having issues downloading rstan from github:

remotes::install_github(“stan-dev/rstan”, ref = “develop”, subdir = “rstan/rstan”)
Downloading GitHub repo stan-dev/rstan@develop
stan-dev-rstan-e634309/StanHeaders/inst/include/libsundials: Can’t create ‘\\?\C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\remotes3048581a439\stan-dev-rstan-e634309\StanHeaders\inst\include\libsundials’
stan-dev-rstan-e634309/StanHeaders/inst/include/src: Can’t create ‘\\?\C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\remotes3048581a439\stan-dev-rstan-e634309\StanHeaders\inst\include\src’
stan-dev-rstan-e634309/StanHeaders/inst/include/stan: Can’t create ‘\\?\C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\remotes3048581a439\stan-dev-rstan-e634309\StanHeaders\inst\include\stan’
tar.exe: Error exit delayed from previous errors.
“C:\PROGRA~1\Git\cmd\git.exe” clone --depth 1 --no-hardlinks --recurse-submodules --branch develop https://github.com/stan-dev/stan.git C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\remotes3048581a439/stan-dev-rstan-e634309/rstan/rstan/…/…/StanHeaders/inst/include/upstream
Error: Failed to install ‘rstan’ from GitHub:
Command failed (128)
In addition: Warning messages:
1: In utils::untar(tarfile, …) :
‘tar.exe -xf “C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\file304833aa1e6b.tar.gz” -C “C:/Users/dja606/AppData/Local/Temp/RtmpULLebl/remotes3048581a439”’ returned error code 1
2: In system(full, intern = TRUE, ignore.stderr = quiet) :
running command ‘“C:\PROGRA~1\Git\cmd\git.exe” clone --depth 1 --no-hardlinks --recurse-submodules --branch develop https://github.com/stan-dev/stan.git C:\Users\dja606\AppData\Local\Temp\RtmpULLebl\remotes3048581a439/stan-dev-rstan-e634309/rstan/rstan/…/…/StanHeaders/inst/include/upstream’ had status 128

That looks like some sort of a permissions problem. Or rogue antivirus software preventing R packages from being installed from GitHub.