# Cmdstan 2.21 compile map\_rect model fails

**URL:** <https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706>\
**Category:** Interfaces\
**Created:** [November 1, 2019, 7:51pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706 "2019-11-01T19:51:17Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 1, 2019, 7:51pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/1 "2019-11-01T19:51:17Z")

</div>

I was able to compile the binomial example model and models that I use that do not have `map_rect` however when I try to compile `map_rect` models in CmdStan they fail even though they compile fine in Rstan. For example, the model from rmcelreath’s repo [https://github.com/rmcelreath/cmdstan\_map\_rect\_tutorial/blob/master/logistic1.stan](https://github.com/rmcelreath/cmdstan_map_rect_tutorial/blob/master/logistic1.stan) compiles fine in Rstan but gives the following error in cmdstan:

```
--- Compiling, linking C++ code ---
g++ -DSTAN_THREADS -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -x c++ -o model/test.o model/test.hpp
In file included from stan/lib/stan_math/stan/math/prim/arr/fun/promote_elements.hpp:5:0,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/promote_elements.hpp:4,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/promote_common.hpp:5,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri_low.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/chol2inv.hpp:7,
                 from stan/lib/stan_math/stan/math/prim/mat.hpp:71,
                 from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
                 from stan/lib/stan_math/stan/math.hpp:4,
                 from stan/src/stan/model/model_header.hpp:4,
                 from model/test.hpp:3:
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp: In instantiation of 'static T stan::math::promote_elements<T, S>::promote(const S&) [with T = double; S = stan::math::var]':
stan/lib/stan_math/stan/math/prim/arr/fun/array_builder.hpp:38:51: required from 'stan::math::array_builder<T>& stan::math::array_builder<T>::add(const S&) [with S = stan::math::var; T = double]'
model/test.hpp:125:60: required from 'Eigen::Matrix<typename boost::math::tools::promote_args<RT1, RT2, A>::type, -1, 1> test_model_namespace::lp_reduce(const Eigen::Matrix<Scalar, -1, 1>&, const Eigen::Matrix<RhsScalar, -1, 1>&, const std::vector<T_l>&, const std::vector<int>&, std::ostream*) [with T0 __= stan::math::var; T1__ = double; T2__ = double; typename boost::math::tools::promote_args<RT1, RT2, A>::type = stan::math::var; std::ostream = std::basic_ostream<char>]'
model/test.hpp:143:48: required from 'Eigen::Matrix<typename boost::math::tools::promote_args<RT1, RT2, A>::type, -1, 1> test_model_namespace::lp_reduce_functor__::operator()(const Eigen::Matrix<Scalar, -1, 1>&, const Eigen::Matrix<RhsScalar, -1, 1>&, const std::vector<T_l>&, const std::vector<int>&, std::ostream*) const [with T0__ = stan::math::var; T1 __= double; T2__ = double; typename boost::math::tools::promote_args<RT1, RT2, A>::type = stan::math::var; std::ostream = std::basic_ostream<char>]'
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_reduce.hpp:112:79: required from 'stan::math::matrix_d stan::math::internal::map_rect_reduce<F, stan::math::var, double>::operator()(const vector_d&, const vector_d&, const std::vector<double>&, const std::vector<int>&, std::ostream*) const [with F = test_model_namespace::lp_reduce_functor__; stan::math::matrix_d = Eigen::Matrix<double, -1, -1>; stan::math::vector_d = Eigen::Matrix<double, -1, 1>; std::ostream = std::basic_ostream<char>]'
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:42:53: required from 'stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*)::<lambda(std::size_t, std::size_t)> [with int call_id = 1; F = test_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; std::size_t = long long unsigned int]'
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:43:7: required from 'struct stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = test_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]::<lambda(std::size_t, std::size_t)>'
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:45:3: required from 'Eigen::Matrix<typename stan::return_type<T1, T2>::type, -1, 1> stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = test_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]'
stan/lib/stan_math/stan/math/prim/mat/functor/map_rect.hpp:175:48: required from 'Eigen::Matrix<typename stan::return_type<T1, T2>::type, -1, 1> stan::math::map_rect(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = test_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]'
model/test.hpp:289:74: required from 'T__test_model_namespace::test_model::log_prob(std::vector<T_l>&, std::vector<int>&, std::ostream*) const [with bool propto__ = false; bool jacobian __= false; T__ = stan::math::var; std::ostream = std::basic_ostream<char>]'
stan/src/stan/model/model_base_crtp.hpp:153:29: required from 'stan::math::var stan::model::model_base_crtp<M>::log_prob(std::vector<stan::math::var>&, std::vector<int>&, std::ostream*) const [with M = test_model_namespace::test_model; std::ostream = std::basic_ostream<char>]'
model/test.hpp:489:1: required from here
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp:24:48: error: cannot convert 'const stan::math::var' to 'double' in return
   inline static T promote(const S& u) { return u; }
                                                ^
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp: In static member function 'static T stan::math::promote_elements<T, S>::promote(const S&) [with T = double; S = stan::math::var]':
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp:24:51: warning: control reaches end of non-void function [-Wreturn-type]
   inline static T promote(const S& u) { return u; }
                                                   ^
make: *** [make/program:43: model\test.exe] Error 1

```

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [November 1, 2019, 7:58pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/2 "2019-11-01T19:58:40Z")

</div>

Did you “make clean-all” and make build upon setting the STAN\_THREADS flag?

If you built cmdstan without stan threads and then build with the flag it will not work.

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 1, 2019, 8:21pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/3 "2019-11-01T20:21:43Z")

</div>

Thanks for the suggestion, I just “make clean-all” and rebuilt using mingw32-make from the previous thread [Cmdstan 2.21 windows can’t make bernoulli example](https://discourse.mc-stan.org/t/cmdstan-2-21-windows-cant-make-bernoulli-example/11704). Prior to rebuilding I made sure the STAN\_THREADS flag was in the `make/local` file. I am still getting the error.

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 1, 2019, 11:31pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/4 "2019-11-01T23:31:18Z")

</div>

FYI, I came home from work and tried cmdstan 2.21 on my mac with Mojave 10.14.6 setting `CXXFLAGS += -DSTAN_THREADS` and then `make clean-all` and rebuilding results with an error as well on the map\_rect example. I can compile and run non-map\_rect models fine.

```
Seans-MBP:cmdstan seanpinkney$ make cmdstan_map_rect_tutorial/logistic1
clang++ -DSTAN_THREADS -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -c -MT stan/src/stan/model/model_header.hpp.gch -MT stan/src/stan/model/model_header.d -MM -E -MG -MP -MF stan/src/stan/model/model_header.d stan/src/stan/model/model_header.hpp

--- Translating Stan model to C++ code ---
bin/stanc --o=cmdstan_map_rect_tutorial/logistic1.hpp cmdstan_map_rect_tutorial/logistic1.stan

--- Compiling, linking C++ code ---
clang++ -DSTAN_THREADS -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -c -include-pch stan/src/stan/model/model_header.hpp.gch -x c++ -o cmdstan_map_rect_tutorial/logistic1.o cmdstan_map_rect_tutorial/logistic1.hpp
In file included from cmdstan_map_rect_tutorial/logistic1.hpp:1:
In file included from stan/src/stan/model/model_header.hpp:4:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math.hpp:4:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/rev/mat.hpp:12:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat.hpp:71:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/chol2inv.hpp:7:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri_low.hpp:6:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri.hpp:6:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/promote_common.hpp:5:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/fun/promote_elements.hpp:4:
In file included from /Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/arr/fun/promote_elements.hpp:5:
/Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp:24:48: error: 
      no viable conversion from returned value of type 'const stan::math::var'
      to function return type 'double'
  inline static T promote(const S& u) { return u; }
                                               ^
/Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/arr/fun/array_builder.hpp:38:42: note: 
      in instantiation of member function 'stan::math::promote_elements<double,
      stan::math::var>::promote' requested here
    x_.push_back(promote_elements<T, S>::promote(u));
                                         ^
cmdstan_map_rect_tutorial/logistic1.hpp:125:45: note: in instantiation of
      function template specialization
      'stan::math::array_builder<double>::add<stan::math::var>' requested here
        stan::math::array_builder<double>().add(lp).array()));
                                            ^
cmdstan_map_rect_tutorial/logistic1.hpp:143:8: note: in instantiation of
      function template specialization
      'logistic1_model_namespace::lp_reduce<stan::math::var, double, double>'
      requested here
return lp_reduce(beta, theta, xr, xi, pstream__);
       ^
/Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_reduce.hpp:112:23: note: 
      in instantiation of function template specialization
      'logistic1_model_namespace::lp_reduce_functor__::operator()<stan::math::var,
      double, double>' requested here
      vector_v fx_v = F()(shared_params_v, job_specific_params, x_r, x_i, msgs);
                      ^
/Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:41:23: note: 
      in instantiation of member function
      'stan::math::internal::map_rect_reduce<logistic1_model_namespace::lp_reduce_functor__,
      stan::math::var, double>::operator()' requested here
      job_output[i] = ReduceF()(shared_params_dbl, value_of(job_params[i]),
                      ^
/Users/seanpinkney/cmdstan/stan/lib/stan_math/stan/math/prim/mat/functor/map_rect.hpp:174:20: note: 
      in instantiation of function template specialization
      'stan::math::internal::map_rect_concurrent<1,
      logistic1_model_namespace::lp_reduce_functor__, stan::math::var, double>'
      requested here
  return internal::map_rect_concurrent<call_id, F, T_shared_param, T_job_param>(
                   ^
cmdstan_map_rect_tutorial/logistic1.hpp:288:28: note: in instantiation of
      function template specialization 'stan::math::map_rect<1,
      logistic1_model_namespace::lp_reduce_functor__, stan::math::var, double>'
      requested here
        lp_accum__.add(sum(map_rect<1, lp_reduce_functor__>(beta, theta, xr,
                           ^
cmdstan_map_rect_tutorial/logistic1.hpp:462:14: note: in instantiation of
      function template specialization
      'logistic1_model_namespace::logistic1_model::log_prob<false, false,
      stan::math::var>' requested here
      return log_prob<propto __,jacobian__ ,T_>(vec_params_r, vec_params_i...
             ^
/Users/seanpinkney/cmdstan/stan/src/stan/model/model_base_crtp.hpp:95:50: note: 
      in instantiation of function template specialization
      'logistic1_model_namespace::logistic1_model::log_prob<false, false,
      stan::math::var>' requested here
    return static_cast<const M*>(this)->template log_prob<false, false>(theta,
                                                 ^
cmdstan_map_rect_tutorial/logistic1.hpp:162:3: note: in instantiation of member
      function
      'stan::model::model_base_crtp<logistic1_model_namespace::logistic1_model>::log_prob'
      requested here
  ~logistic1_model() { }
  ^
1 error generated.
make: *** [cmdstan_map_rect_tutorial/logistic1] Error 1

```

---

<div class="post-metadata">

**Author:** ![psadil](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/psadil/32/1603_2.png) [@psadil](https://discourse.mc-stan.org/u/psadil)\
**Post date:** [November 6, 2019, 2:10pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/5 "2019-11-06T14:10:49Z")

</div>

FWIW, I ran in to what looks like a similar issue while trying to get rmcelreath’s example working using a freshly cloned version of cmdstan ([991360f](https://github.com/stan-dev/cmdstan/commit/991360fe6cb8ae17892b204322dd6bb6c6d529b5)). But the model complies fine when downloading and unpacking the [latest release](https://github.com/stan-dev/cmdstan/releases/tag/v2.21.0).

Ubuntu 18.04  
g++ 7.4.0

That is, the following

```
git clone https://github.com/stan-dev/cmdstan.git --recursive 
make stan-update
echo "CXXFLAGS += -DSTAN_THREADS" > make/local
make build
make redcard/logistic1

```

results in an error

```
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp:24:48: error: cannot convert ‘const stan::math::var’ to ‘double’ in return
   inline static T promote(const S& u) { return u; }
                                                ^

```

full output below

```
--- Translating Stan model to C++ code ---
bin/stanc --o=redcard/logistic1.hpp redcard/logistic1.stan

--- Compiling, linking C++ code ---
g++ -DSTAN_THREADS -std=c++1y -pthread -D_REENTRANT -Wno-sign-compare -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -c -x c++ -o redcard/logistic1.o redcard/logistic1.hpp
In file included from stan/lib/stan_math/stan/math/prim/arr/fun/promote_elements.hpp:5:0,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/promote_elements.hpp:4,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/promote_common.hpp:5,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/mdivide_left_tri_low.hpp:6,
                 from stan/lib/stan_math/stan/math/prim/mat/fun/chol2inv.hpp:7,
                 from stan/lib/stan_math/stan/math/prim/mat.hpp:71,
                 from stan/lib/stan_math/stan/math/rev/mat.hpp:12,
                 from stan/lib/stan_math/stan/math.hpp:4,
                 from stan/src/stan/model/model_header.hpp:4,
                 from redcard/logistic1.hpp:3:
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp: In instantiation of ‘static T stan::math::promote_elements<T, S>::promote(const S&) [with T = double; S = stan::math::var]’:
stan/lib/stan_math/stan/math/prim/arr/fun/array_builder.hpp:38:49: required from ‘stan::math::array_builder<T>& stan::math::array_builder<T>::add(const S&) [with S = stan::math::var; T = double]’
redcard/logistic1.hpp:125:53: required from ‘Eigen::Matrix<typename boost::math::tools::promote_args<RT1, RT2, A>::type, -1, 1> logistic1_model_namespace::lp_reduce(const Eigen::Matrix<Scalar, -1, 1>&, const Eigen::Matrix<RhsScalar, -1, 1>&, const std::vector<T_l>&, const std::vector<int>&, std::ostream*) [with T0 __= stan::math::var; T1__ = double; T2__ = double; typename boost::math::tools::promote_args<RT1, RT2, A>::type = stan::math::var; std::ostream = std::basic_ostream<char>]’
redcard/logistic1.hpp:143:17: required from ‘Eigen::Matrix<typename boost::math::tools::promote_args<RT1, RT2, A>::type, -1, 1> logistic1_model_namespace::lp_reduce_functor__::operator()(const Eigen::Matrix<Scalar, -1, 1>&, const Eigen::Matrix<RhsScalar, -1, 1>&, const std::vector<T_l>&, const std::vector<int>&, std::ostream*) const [with T0__ = stan::math::var; T1 __= double; T2__ = double; typename boost::math::tools::promote_args<RT1, RT2, A>::type = stan::math::var; std::ostream = std::basic_ostream<char>]’
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_reduce.hpp:112:26: required from ‘stan::math::matrix_d stan::math::internal::map_rect_reduce<F, stan::math::var, double>::operator()(const vector_d&, const vector_d&, const std::vector<double>&, const std::vector<int>&, std::ostream*) const [with F = logistic1_model_namespace::lp_reduce_functor__; stan::math::matrix_d = Eigen::Matrix<double, -1, -1>; stan::math::vector_d = Eigen::Matrix<double, -1, 1>; std::ostream = std::basic_ostream<char>]’
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:41:32: required from ‘stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*)::<lambda(std::size_t, std::size_t)> [with int call_id = 1; F = logistic1_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; std::size_t = long unsigned int]’
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:43:7: required from ‘struct stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = logistic1_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]::<lambda(std::size_t, std::size_t)>’
stan/lib/stan_math/stan/math/rev/mat/functor/map_rect_concurrent.hpp:39:8: required from ‘Eigen::Matrix<typename stan::return_type<T1, T2>::type, -1, 1> stan::math::internal::map_rect_concurrent(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = logistic1_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]’
stan/lib/stan_math/stan/math/prim/mat/functor/map_rect.hpp:174:80: required from ‘Eigen::Matrix<typename stan::return_type<T1, T2>::type, -1, 1> stan::math::map_rect(const Eigen::Matrix<T_shared_param, -1, 1>&, const std::vector<Eigen::Matrix<T_job_param, -1, 1> >&, const std::vector<std::vector<double> >&, const std::vector<std::vector<int> >&, std::ostream*) [with int call_id = 1; F = logistic1_model_namespace::lp_reduce_functor__; T_shared_param = stan::math::var; T_job_param = double; typename stan::return_type<T1, T2>::type = stan::math::var; std::ostream = std::basic_ostream<char>]’
redcard/logistic1.hpp:288:60: required from ‘T__logistic1_model_namespace::logistic1_model::log_prob(std::vector<T_l>&, std::vector<int>&, std::ostream*) const [with bool propto__ = false; bool jacobian __= false; T__ = stan::math::var; std::ostream = std::basic_ostream<char>]’
stan/src/stan/model/model_base_crtp.hpp:153:29: required from ‘stan::math::var stan::model::model_base_crtp<M>::log_prob(std::vector<stan::math::var>&, std::vector<int>&, std::ostream*) const [with M = logistic1_model_namespace::logistic1_model; std::ostream = std::basic_ostream<char>]’
redcard/logistic1.hpp:489:1: required from here
stan/lib/stan_math/stan/math/prim/scal/fun/promote_elements.hpp:24:48: error: cannot convert ‘const stan::math::var’ to ‘double’ in return
   inline static T promote(const S& u) { return u; }
                                                ^
make/program:41: recipe for target 'redcard/logistic1' failed
make: *** [redcard/logistic1] Error 1

```

But all seems well with the latest release

```
--- Translating Stan model to C++ code ---
bin/stanc --o=redcard/logistic1.hpp redcard/logistic1.stan
Model name=logistic1_model
Input file=redcard/logistic1.stan
Output file=redcard/logistic1.hpp
DIAGNOSTIC(S) FROM PARSER:
Info: integer division implicitly rounds to integer. Found int division: N / n_shards
 Positive values rounded down, negative values rounded up or down in platform-dependent way.

--- Compiling, linking C++ code ---
g++ -DSTAN_THREADS -std=c++1y -pthread -D_REENTRANT -Wno-sign-compare -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -c -x c++ -o redcard/logistic1.o redcard/logistic1.hpp
g++ -DSTAN_THREADS -std=c++1y -pthread -D_REENTRANT -Wno-sign-compare -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.69.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -DBOOST_DISABLE_ASSERTS -Wl,-L,"/home/psadil/.cmdstanr/cmdstan/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"/home/psadil/.cmdstanr/cmdstan/stan/lib/stan_math/lib/tbb" redcard/logistic1.o src/cmdstan/main.o stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_kinsol.a stan/lib/stan_math/lib/tbb/libtbb.so.2 -o redcard/logistic1

```

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 6, 2019, 3:44pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/6 "2019-11-06T15:44:32Z")

</div>

I removed cmdstan and re-cloned. I’m still getting the error on windows. I’ll test on my mac when I get home.

---

<div class="post-metadata">

**Author:** ![psadil](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/psadil/32/1603_2.png) [@psadil](https://discourse.mc-stan.org/u/psadil)\
**Post date:** [November 6, 2019, 3:49pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/7 "2019-11-06T15:49:20Z")

</div>

Sorry, I meant that nothing I cloned could compile logistic1.stan. What worked came from manually downloading the .tar.gz file on the releases page (unpacking that, adding DSTAN\_THREADS flag, rebuilding, then compiling).

---

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [November 6, 2019, 4:05pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/8 "2019-11-06T16:05:21Z")

</div>

The current develop CmdStan uses the new stanc3 parser. Tagging @seantalts …

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 6, 2019, 4:24pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/9 "2019-11-06T16:24:18Z")

</div>

Ah ok, I was hopeful since the diff log from what I had previously did show some commits. Will try with the tar.gz file.  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/5/515cac196a0b8172d19eaa6cece06555ed6f3b6a.png)

---

<div class="post-metadata">

**Author:** ![seantalts](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/seantalts/32/32_2.png) [@seantalts](https://discourse.mc-stan.org/u/seantalts)\
**Post date:** [November 6, 2019, 4:40pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/10 "2019-11-06T16:40:30Z")

</div>

I’ll take a look at that model, thanks!

You can always use git to check out a different tag, `git checkout master && make clean-all` should get you to the same code included in the .tar.gz.

---

<div class="post-metadata">

**Author:** ![spinkney](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@spinkney](https://discourse.mc-stan.org/u/spinkney)\
**Post date:** [November 6, 2019, 8:06pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/11 "2019-11-06T20:06:06Z")

</div>

I’m confirming that `git checkout master && make clean-all` branch works. Thanks @seantalts and @psadil!

---

<div class="post-metadata">

**Author:** ![seantalts](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/seantalts/32/32_2.png) [@seantalts](https://discourse.mc-stan.org/u/seantalts)\
**Post date:** [November 7, 2019, 9:17pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/12 "2019-11-07T21:17:19Z")

</div>

Just merged a fix to stanc3 - should be in the [next build](https://jenkins.mc-stan.org/blue/organizations/jenkins/stanc3/detail/master/556/pipeline) and should propagate to cmdstan develop. If you’re currently on develop, running a `make clean-all` before your next build should cause the new one to be downloaded for you.

---

<div class="post-metadata">

**Author:** ![anon75146577](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@anon75146577](https://discourse.mc-stan.org/u/anon75146577)\
**Post date:** [November 7, 2019, 9:29pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/13 "2019-11-07T21:29:08Z")

</div>

> [@seantalts](#):
>
> If you’re currently on develop, running a `make clean-all` before your next build should cause the new one to be downloaded for you.

@mitzimorris @jonah do the CmdStanPy/R install functions do this?

---

<div class="post-metadata">

**Author:** ![mitzimorris](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mitzimorris/32/29_2.png) [@mitzimorris](https://discourse.mc-stan.org/u/mitzimorris)\
**Post date:** [November 7, 2019, 10:10pm UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/14 "2019-11-07T22:10:17Z")

</div>

> [@anon75146577](#):
>
> do the CmdStanPy/R install functions do this?

by default, the install function gets the latest release or a specified release, but it doesn’t install from develop.

the install function downloads and unzips the release, which is in a clean state, so `make clean-all` isn’t necessary.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [November 8, 2019, 12:09am UTC](https://discourse.mc-stan.org/t/cmdstan-2-21-compile-map-rect-model-fails/11706/15 "2019-11-08T00:09:27Z")

</div>

> [@anon75146577](#):
>
> @mitzimorris @jonah do the CmdStanPy/R install functions do this?

CmdStanR installs the latest release from tarball by default, although thanks to @rok_cesnovar it does now also let you install from develop or any other branch you want:

> **[Install CmdStan or clean and rebuild an existing installation — install\_cmdstan](https://mc-stan.org/cmdstanr/reference/install_cmdstan.html)**
>
> The install\_cmdstan() function attempts to download and
> install the latest release of CmdStan.
> Installing a previous release or a new release candidate is also possible
> by specifying the version or release\_url argument.
> See the first few sections of...

[https://mc-stan.org/cmdstanr/reference/cmdstan\_git\_checkout\_branch.html](https://mc-stan.org/cmdstanr/reference/cmdstan_git_checkout_branch.html)
