compilation failed for package ‘rstan’

In some cases rstan fails on installation:

::proto::argsns_::list6<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<stan::lang::binary_op_expr>, 0l>, boost::phoenix::actor<boost::spirit::attribute<0> >, boost::phoenix::actor<boost::spirit::argument<0> >, boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<char*>, 0l>, boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<char*>, 0l>, boost::phoenix::actor<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::reference_wrapper<std::__cxx11::basic_stringstream<char> > >, 0l> > >, 6l> >]’
         static type make(typename call_traits<A>::param_type... a)
                     ^~~~
/usr/local/lib/R/etc/Makeconf:168: recipe for target 'lang__grammars__expression_grammar_inst.o' failed
make: *** [lang__grammars__expression_grammar_inst.o] Error 1
ERROR: compilation failed for package ‘rstan’

But there is a short workaround. You just have to edit or create a Makevar file (~/.R/Makevars) and add the following line to it. If there is already such a variable, just append the flag.

CXXFLAGS=-DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION

Links