Dealing with Catalina

Can someone with a Mac and a lot of experience upgrade their operating system to Catalina (and Xcode) and tell us if there are any new problems (and solutions) with running Stan beyond what we accumulated for Mojave


If you don’t have a lot of experience with this sort of thing and you need to use Stan in the near future, I would not recommend updating to Catalina right away.

It seems as if a previous problem with exception handling has reemerged.

Also,

1 Like

In case nobody else volunteers for this, if someone has an extra Catalina virtual machine they could give me access to, I am willing to use it to test Stan and make sure things compile.

Hi

I upgraded by mistake :( Well, I fired up RStudio and ran my script I worked on yesterday (after having updated Xcode and the command line tools, and accepting the license agreement). Now, I get an error.

I use brms and it compiles and starts sampling but then during warmup I get this:

Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
[1] “Error in sampler$call_sampler(args_list[[i]]) : "
[2] " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done

2 Likes

I suspected a threading issue at first, but the same thing happens running with only one chain. I’ll reinstall rstan etc. next.

removing rstan and installing from source did not help either. Same thing happens.

Just tell me what you need from me @bgoodri to debug this thing.

~>pkgbuild::has_build_tools(debug = TRUE)
[1] TRUE

When I run the 8 schools example it works, i.e., https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

~> cat .R/Makevars
CXX14FLAGS=-O3 -march=native -mtune=native
CXX14FLAGS += -arch x86_64 -ftemplate-depth-256

Do

library(rstan) # needs 2.19.x
example(stan_model, run.dontrun = TRUE)

Sorry @bgoodri normally I’d be up for helping with this but I’m about to do a whole bunch of simulations I need done I can’t afford the risk of Cantina messing that up on me right now.

Reinstall RCpp from source as well is usually also helpful.

@bgoodri, it sampled without a problem. I’ll reinstall RCpp also now as @wds15 recommended.

Sorry @wds15, I recompiled rcpp from source and now another model experiences the same problem. I’ll post the code w/ data next.

Here’s the code w/ data.
foo.R (1.8 KB)

So, example(stan_model, run.dontrun = TRUE) works but foo.R doesn’t? That would suggest that invalid C++ code is getting generated rather than a compiler problem. Can you do

library(rstan)
library(brms)
post <- stan(model_code = make_stan_code(y ~ 1 + (1 | algorithm), data = df),
                    data = make_stan_data(y ~ 1 + (1 | algorithm), data = df), 
                    verbose = TRUE)

?

@bgoodri, you’re right, the first example you have works, but your second example bails for me. Here’s the output. I’ll change flights soon and when I’ve arrived I’ll check again for any things you want me to check out.
output.txt (57.6 KB)

OK, what version of clang++ comes with Xcode these days? Or are you using clang++ from @coatless 's script? This looks like it may be a return of
https://stat.ethz.ch/pipermail/r-sig-mac/2017-September/012490.html
@jonah or some other Mac guru, can you replicate this?

I do not run @coatless clang++. This is pure Xcode which was updated just the other day:

@~$ clang++ --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

@torkar please either run the installer here:

Or follow the steps here:

https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

Using only the clang available in Xcode is a bad idea in the era of R 3.5.* - Present (R 3.6.*)

Will try in a few hours!

I don’t think this works since the functions are named wrong?

Error in make_stan_data(y ~ 1 + (1 | algorithm), data = df) :
could not find function “make_stan_data”


This works.

Build and sampling details

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

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

TRANSLATING MODEL ‘16a540c6086086816528e4524def24d9’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘16a540c6086086816528e4524def24d9’.
COMPILING THE C++ CODE FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW.
OS: x86_64, darwin15.6.0; rstan: 2.19.2; Rcpp: 1.0.2; inline: 0.3.15

setting environment variables:
PKG_LIBS = -L’/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/lib/’ -lStanHeaders
PKG_CPPFLAGS = -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS

Program source :

1 :
2 : // includes from the plugin
3 : // [[Rcpp::plugins(cpp14)]]
4 :
5 : // user includes
6 : #define STAN__SERVICES__COMMAND_HPP// Code generated by Stan version 2.19.1
7 :
8 : #include <stan/model/model_header.hpp>
9 :
10 : namespace modeldee1452d10_16a540c6086086816528e4524def24d9_namespace {
11 :
12 : using std::istream;
13 : using std::string;
14 : using std::stringstream;
15 : using std::vector;
16 : using stan::io::dump;
17 : using stan::math::lgamma;
18 : using stan::model::prob_grad;
19 : using namespace stan::math;
20 :
21 : static int current_statement_begin__;
22 :
23 : stan::io::program_reader prog_reader__() {
24 : stan::io::program_reader reader;
25 : reader.add_event(0, 0, “start”, “modeldee1452d10_16a540c6086086816528e4524def24d9”);
26 : reader.add_event(3, 1, “end”, “modeldee1452d10_16a540c6086086816528e4524def24d9”);
27 : return reader;
28 : }
29 :
30 : class modeldee1452d10_16a540c6086086816528e4524def24d9 : public prob_grad {
31 : private:
32 : double y_mean;
33 : public:
34 : modeldee1452d10_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
35 : std::ostream* pstream__ = 0)
36 : : prob_grad(0) {
37 : ctor_body(context__, 0, pstream__);
38 : }
39 :
40 : modeldee1452d10_16a540c6086086816528e4524def24d9(stan::io::var_context& context__,
41 : unsigned int random_seed__,
42 : std::ostream* pstream__ = 0)
43 : : prob_grad(0) {
44 : ctor_body(context__, random_seed__, pstream__);
45 : }
46 :
47 : void ctor_body(stan::io::var_context& context__,
48 : unsigned int random_seed__,
49 : std::ostream* pstream__) {
50 : typedef double local_scalar_t__;
51 :
52 : boost::ecuyer1988 base_rng__ =
53 : stan::services::util::create_rng(random_seed__, 0);
54 : (void) base_rng__; // suppress unused var warning
55 :
56 : current_statement_begin__ = -1;
57 :
58 : static const char* function__ = “modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9”;
59 : (void) function__; // dummy to suppress unused var warning
60 : size_t pos__;
61 : (void) pos__; // dummy to suppress unused var warning
62 : std::vector vals_i__;
63 : std::vector vals_r__;
64 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
65 : (void) DUMMY_VAR__; // suppress unused var warning
66 :
67 : try {
68 : // initialize data block variables from context__
69 : current_statement_begin__ = 1;
70 : context__.validate_dims(“data initialization”, “y_mean”, “double”, context__.to_vec());
71 : y_mean = double(0);
72 : vals_r__ = context__.vals_r(“y_mean”);
73 : pos__ = 0;
74 : y_mean = vals_r__[pos__++];
75 :
76 :
77 : // initialize transformed data variables
78 : // execute transformed data statements
79 :
80 : // validate transformed data
81 :
82 : // validate, set parameter ranges
83 : num_params_r__ = 0U;
84 : param_ranges_i__.clear();
85 : current_statement_begin__ = 1;
86 : num_params_r__ += 1;
87 : } catch (const std::exception& e) {
88 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
89 : // Next line prevents compiler griping about no return
90 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
91 : }
92 : }
93 :
94 : ~modeldee1452d10_16a540c6086086816528e4524def24d9() { }
95 :
96 :
97 : void transform_inits(const stan::io::var_context& context__,
98 : std::vector& params_i__,
99 : std::vector& params_r__,
100 : std::ostream
pstream__) const {
101 : typedef double local_scalar_t__;
102 : stan::io::writer writer__(params_r__, params_i__);
103 : size_t pos__;
104 : (void) pos__; // dummy call to supress warning
105 : std::vector vals_r__;
106 : std::vector vals_i__;
107 :
108 : current_statement_begin__ = 1;
109 : if (!(context__.contains_r(“y”)))
110 : stan::lang::rethrow_located(std::runtime_error(std::string(“Variable y missing”)), current_statement_begin__, prog_reader__());
111 : vals_r__ = context__.vals_r(“y”);
112 : pos__ = 0U;
113 : context__.validate_dims(“parameter initialization”, “y”, “double”, context__.to_vec());
114 : double y(0);
115 : y = vals_r__[pos__++];
116 : try {
117 : writer__.scalar_unconstrain(y);
118 : } catch (const std::exception& e) {
119 : stan::lang::rethrow_located(std::runtime_error(std::string("Error transforming variable y: ") + e.what()), current_statement_begin__, prog_reader__());
120 : }
121 :
122 : params_r__ = writer__.data_r();
123 : params_i__ = writer__.data_i();
124 : }
125 :
126 : void transform_inits(const stan::io::var_context& context,
127 : Eigen::Matrix<double, Eigen::Dynamic, 1>& params_r,
128 : std::ostream
pstream__) const {
129 : std::vector params_r_vec;
130 : std::vector params_i_vec;
131 : transform_inits(context, params_i_vec, params_r_vec, pstream__);
132 : params_r.resize(params_r_vec.size());
133 : for (int i = 0; i < params_r.size(); ++i)
134 : params_r(i) = params_r_vec[i];
135 : }
136 :
137 :
138 : template <bool propto__, bool jacobian__, typename T__>
139 : T__ log_prob(std::vector<T__>& params_r__,
140 : std::vector& params_i__,
141 : std::ostream
pstream__ = 0) const {
142 :
143 : typedef T__ local_scalar_t__;
144 :
145 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
146 : (void) DUMMY_VAR__; // dummy to suppress unused var warning
147 :
148 : T__ lp__(0.0);
149 : stan::math::accumulator<T__> lp_accum__;
150 : try {
151 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
152 :
153 : // model parameters
154 : current_statement_begin__ = 1;
155 : local_scalar_t__ y;
156 : (void) y; // dummy to suppress unused var warning
157 : if (jacobian__)
158 : y = in__.scalar_constrain(lp__);
159 : else
160 : y = in__.scalar_constrain();
161 :
162 : // model body
163 :
164 : current_statement_begin__ = 1;
165 : lp_accum__.add(normal_log<propto__>(y, y_mean, 1));
166 :
167 : } catch (const std::exception& e) {
168 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
169 : // Next line prevents compiler griping about no return
170 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
171 : }
172 :
173 : lp_accum__.add(lp__);
174 : return lp_accum__.sum();
175 :
176 : } // log_prob()
177 :
178 : template <bool propto, bool jacobian, typename T_>
179 : T_ log_prob(Eigen::Matrix<T_,Eigen::Dynamic,1>& params_r,
180 : std::ostream
pstream = 0) const {
181 : std::vector<T_> vec_params_r;
182 : vec_params_r.reserve(params_r.size());
183 : for (int i = 0; i < params_r.size(); ++i)
184 : vec_params_r.push_back(params_r(i));
185 : std::vector vec_params_i;
186 : return log_prob<propto,jacobian,T_>(vec_params_r, vec_params_i, pstream);
187 : }
188 :
189 :
190 : void get_param_names(std::vectorstd::string& names__) const {
191 : names__.resize(0);
192 : names__.push_back(“y”);
193 : }
194 :
195 :
196 : void get_dims(std::vector<std::vector<size_t> >& dimss__) const {
197 : dimss__.resize(0);
198 : std::vector<size_t> dims__;
199 : dims__.resize(0);
200 : dimss__.push_back(dims__);
201 : }
202 :
203 : template
204 : void write_array(RNG& base_rng__,
205 : std::vector& params_r__,
206 : std::vector& params_i__,
207 : std::vector& vars__,
208 : bool include_tparams__ = true,
209 : bool include_gqs__ = true,
210 : std::ostream
pstream__ = 0) const {
211 : typedef double local_scalar_t__;
212 :
213 : vars__.resize(0);
214 : stan::io::reader<local_scalar_t__> in__(params_r__, params_i__);
215 : static const char
function__ = “modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::write_array”;
216 : (void) function__; // dummy to suppress unused var warning
217 :
218 : // read-transform, write parameters
219 : double y = in__.scalar_constrain();
220 : vars__.push_back(y);
221 :
222 : double lp__ = 0.0;
223 : (void) lp__; // dummy to suppress unused var warning
224 : stan::math::accumulator lp_accum__;
225 :
226 : local_scalar_t__ DUMMY_VAR__(std::numeric_limits::quiet_NaN());
227 : (void) DUMMY_VAR__; // suppress unused var warning
228 :
229 : if (!include_tparams__ && !include_gqs__) return;
230 :
231 : try {
232 : if (!include_gqs__ && !include_tparams__) return;
233 : if (!include_gqs__) return;
234 : } catch (const std::exception& e) {
235 : stan::lang::rethrow_located(e, current_statement_begin__, prog_reader__());
236 : // Next line prevents compiler griping about no return
237 : throw std::runtime_error("*** IF YOU SEE THIS, PLEASE REPORT A BUG ");
238 : }
239 : }
240 :
241 : template
242 : void write_array(RNG& base_rng,
243 : Eigen::Matrix<double,Eigen::Dynamic,1>& params_r,
244 : Eigen::Matrix<double,Eigen::Dynamic,1>& vars,
245 : bool include_tparams = true,
246 : bool include_gqs = true,
247 : std::ostream
pstream = 0) const {
248 : std::vector params_r_vec(params_r.size());
249 : for (int i = 0; i < params_r.size(); ++i)
250 : params_r_vec[i] = params_r(i);
251 : std::vector vars_vec;
252 : std::vector params_i_vec;
253 : write_array(base_rng, params_r_vec, params_i_vec, vars_vec, include_tparams, include_gqs, pstream);
254 : vars.resize(vars_vec.size());
255 : for (int i = 0; i < vars.size(); ++i)
256 : vars(i) = vars_vec[i];
257 : }
258 :
259 : static std::string model_name() {
260 : return “modeldee1452d10_16a540c6086086816528e4524def24d9”;
261 : }
262 :
263 :
264 : void constrained_param_names(std::vectorstd::string& param_names__,
265 : bool include_tparams__ = true,
266 : bool include_gqs__ = true) const {
267 : std::stringstream param_name_stream__;
268 : param_name_stream__.str(std::string());
269 : param_name_stream__ << “y”;
270 : param_names__.push_back(param_name_stream__.str());
271 :
272 : if (!include_gqs__ && !include_tparams__) return;
273 :
274 : if (include_tparams__) {
275 : }
276 :
277 : if (!include_gqs__) return;
278 : }
279 :
280 :
281 : void unconstrained_param_names(std::vectorstd::string& param_names__,
282 : bool include_tparams__ = true,
283 : bool include_gqs__ = true) const {
284 : std::stringstream param_name_stream__;
285 : param_name_stream__.str(std::string());
286 : param_name_stream__ << “y”;
287 : param_names__.push_back(param_name_stream__.str());
288 :
289 : if (!include_gqs__ && !include_tparams__) return;
290 :
291 : if (include_tparams__) {
292 : }
293 :
294 : if (!include_gqs__) return;
295 : }
296 :
297 : }; // model
298 :
299 : } // namespace
300 :
301 : typedef modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9 stan_model;
302 :
303 : #include <rstan/rstaninc.hpp>
304 : /

305 : * Define Rcpp Module to expose stan_fit’s functions to R.
306 : */
307 : RCPP_MODULE(stan_fit4modeldee1452d10_16a540c6086086816528e4524def24d9_mod){
308 : Rcpp::class_<rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9,
309 : boost::random::ecuyer1988> >(“stan_fit4modeldee1452d10_16a540c6086086816528e4524def24d9”)
310 : // .constructorRcpp::List()
311 : .constructor<SEXP, SEXP, SEXP>()
312 : // .constructor<SEXP, SEXP>()
313 : .method(“call_sampler”,
314 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::call_sampler)
315 : .method(“param_names”,
316 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names)
317 : .method(“param_names_oi”,
318 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_names_oi)
319 : .method(“param_fnames_oi”,
320 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_fnames_oi)
321 : .method(“param_dims”,
322 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims)
323 : .method(“param_dims_oi”,
324 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_dims_oi)
325 : .method(“update_param_oi”,
326 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::update_param_oi)
327 : .method(“param_oi_tidx”,
328 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::param_oi_tidx)
329 : .method(“grad_log_prob”,
330 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::grad_log_prob)
331 : .method(“log_prob”,
332 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::log_prob)
333 : .method(“unconstrain_pars”,
334 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrain_pars)
335 : .method(“constrain_pars”,
336 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrain_pars)
337 : .method(“num_pars_unconstrained”,
338 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::num_pars_unconstrained)
339 : .method(“unconstrained_param_names”,
340 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::unconstrained_param_names)
341 : .method(“constrained_param_names”,
342 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::constrained_param_names)
343 : .method(“standalone_gqs”,
344 : &rstan::stan_fit<modeldee1452d10_16a540c6086086816528e4524def24d9_namespace::modeldee1452d10_16a540c6086086816528e4524def24d9, boost::random::ecuyer1988>::standalone_gqs)
345 : ;
346 : }
347 :
348 : // declarations
349 : extern “C” {
350 : SEXP filedee454fa6f9( ) ;
351 : }
352 :
353 : // definition
354 :
355 : SEXP filedee454fa6f9( ){
356 : return Rcpp::wrap(“16a540c6086086816528e4524def24d9”);
357 : }
358 :
359 :
Compilation argument:
/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB filedee454fa6f9.cpp 2> filedee454fa6f9.cpp.err.txt
clang++ -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c filedee454fa6f9.cpp -o filedee454fa6f9.o
clang++ -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o filedee454fa6f9.so filedee454fa6f9.o -L/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/lib/ -lStanHeaders -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation
In file included from filedee454fa6f9.cpp:8:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/src/stan/model/model_header.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:5:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/rev/core/build_vari_array.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:535:
/Library/Frameworks/R.framework/Versions/3.6/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 filedee454fa6f9.cpp:8:
stn_mdR> fit <- sampling(mod, data = list(y_mean = 0))

(truncated errors)

SAMPLING FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 7e-06 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.07 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
Chain 1: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 1: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 1: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 1: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 1: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 1:
Chain 1: Elapsed Time: 0.011142 seconds (Warm-up)
Chain 1: 0.00953 seconds (Sampling)
Chain 1: 0.020672 seconds (Total)
Chain 1:

SAMPLING FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 2e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.02 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2:
Chain 2: Elapsed Time: 0.008622 seconds (Warm-up)
Chain 2: 0.01019 seconds (Sampling)
Chain 2: 0.018812 seconds (Total)
Chain 2:

SAMPLING FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW (CHAIN 3).
Chain 3:
Chain 3: Gradient evaluation took 3e-06 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.03 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3:
Chain 3:
Chain 3: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 3: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 3: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 3: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 3: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 3:
Chain 3: Elapsed Time: 0.0086 seconds (Warm-up)
Chain 3: 0.007962 seconds (Sampling)
Chain 3: 0.016562 seconds (Total)
Chain 3:

SAMPLING FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW (CHAIN 4).
Chain 4:
Chain 4: Gradient evaluation took 1e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.01 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4:
Chain 4:
Chain 4: Iteration: 1 / 2000 [ 0%] (Warmup)
Chain 4: Iteration: 200 / 2000 [ 10%] (Warmup)
Chain 4: Iteration: 400 / 2000 [ 20%] (Warmup)
Chain 4: Iteration: 600 / 2000 [ 30%] (Warmup)
Chain 4: Iteration: 800 / 2000 [ 40%] (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4:
Chain 4: Elapsed Time: 0.008115 seconds (Warm-up)
Chain 4: 0.008177 seconds (Sampling)
Chain 4: 0.016292 seconds (Total)
Chain 4:

stn_mdR> fit2 <- sampling(mod, data = list(y_mean = 5))

SAMPLING FOR MODEL ‘16a540c6086086816528e4524def24d9’ NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 6e-06 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.06 seconds.

FYI, the installer package for SDK headers is no longer available. Compilation flags need to be set in Makevars to point to the new location. (Yay, macOS.)

I think you omitted the library(brms), but it will probably work for you.