# R package using rstantools fails to install

**URL:** <https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562>\
**Category:** General\
**Created:** [March 14, 2018, 10:22pm UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562 "2018-03-14T22:22:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wjakethompson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wjakethompson/32/857_2.png) [@wjakethompson](https://discourse.mc-stan.org/u/wjakethompson)\
**Post date:** [March 14, 2018, 10:22pm UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562/1 "2018-03-14T22:22:25Z")

</div>

I’m trying to create an R package that includes Stan models, using the rstantools infrastructure. The GitHub repo is here: [https://github.com/wjakethompson/measurrr](https://github.com/wjakethompson/measurrr)

However, when I try to install the package, it fails. This happens, for example, when I attempt to update the documentation using roxygen2:

```
> devtools::document()
Updating measurrr documentation
Loading measurrr
Re-compiling measurrr
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save \
  --no-restore --quiet CMD INSTALL '/Users/jakethompson/Documents/GIT/packages/measurrr' \
  --library='/var/folders/h4/wk23d6yd4q57b_prqv6z7yqm0000gn/T//Rtmpkg2wPL/devtools_install_f58429475de' \
  --no-R --no-data --no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch \
  --no-test-load --preclean 

* installing *source* package ‘measurrr’ ...
** libs
rm: stan_files/: is a directory
make: *** [shlib-clean] Error 1
/usr/local/clang4/bin/clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"../inst/include" -I"`"/Library/Frameworks/R.framework/Resources/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=ignore_error -I"/Users/jakethompson/R/BH/include" -I"/Users/jakethompson/R/Rcpp/include" -I"/Users/jakethompson/R/RcppEigen/include" -I"/Users/jakethompson/R/rstan/include" -I"/Users/jakethompson/R/StanHeaders/include" -I/usr/local/include -fPIC -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c init.cpp -o init.o
/usr/local/clang4/bin/clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/clang4/lib -o measurrr.so stan_files/ init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: can't map file, errno=22 file 'stan_files/' for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [measurrr.so] Error 1
ERROR: compilation failed for package ‘measurrr’
* removing ‘/private/var/folders/h4/wk23d6yd4q57b_prqv6z7yqm0000gn/T/Rtmpkg2wPL/devtools_install_f58429475de/measurrr’
Error: Command failed (1)

```

From this, it appears that the `stan_files/` directory is being removed, which is then causing problems down stream. Is there a reason this is happening, or something I need to do prevent this behavior?

If it is helpful, the travis build is here: [https://travis-ci.org/wjakethompson/measurrr/builds](https://travis-ci.org/wjakethompson/measurrr/builds)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 14, 2018, 11:06pm UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562/2 "2018-03-14T23:06:33Z")

</div>

Sorry, I had some changes that made it onto CRAN but I forgot to push into the **rstanarm** repository, which is used by `rstantools::rstan_package.skeleton`. Can you call `rstantools::rstan_package.skeleton` and then copy your .R files to R/ and your .stan files to src/stan\_files. You will also need to add

```
SystemRequirements: GNU make

```

to your DESCRIPTION file in order to get it to build on Solaris. If you have any further difficulties, be sure to let us know.

---

<div class="post-metadata">

**Author:** ![wjakethompson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wjakethompson/32/857_2.png) [@wjakethompson](https://discourse.mc-stan.org/u/wjakethompson)\
**Post date:** [March 15, 2018, 12:08am UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562/3 "2018-03-15T00:08:41Z")

</div>

Thanks! This solved that problem, but it appears that something is still off. I’ve pushed the changes to the repo, and the full error is below, but here is section of the output that seems to be indicating the problem:

```
/usr/local/clang4/bin/../include/c++/v1/__config:388:52: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_STD'
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
                                                   ^
stan_files/uni-irt.cc:5:1: error: variable has incomplete type 'void'
RCPP_MODULE(stan_fit4uni-irt_mod) {
^
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:429:10: note: expanded from macro 'RCPP_MODULE'
    void _rcpp_module_##name##_init() ; \
         ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
RCPP_MODULE(stan_fit4uni-irt_mod) {
                        ^
stan_files/uni-irt.cc:5:1: error: static declaration of '_rcpp_module_stan_fit4uni' follows non-static declaration
RCPP_MODULE(stan_fit4uni-irt_mod) {
^
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:430:25: note: expanded from macro 'RCPP_MODULE'
    static Rcpp::Module _rcpp_module_##name( # name ) ; \
                        ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:1: note: previous definition is here
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:429:10: note: expanded from macro 'RCPP_MODULE'
    void _rcpp_module_##name##_init() ; \
         ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
RCPP_MODULE(stan_fit4uni-irt_mod) {
                        ^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
15 warnings and 5 errors generated.
make: *** [stan_files/uni-irt.o] Error 1
rm stan_files/uni-irt.cc
ERROR: compilation failed for package ‘measurrr’
* removing ‘/private/var/folders/h4/wk23d6yd4q57b_prqv6z7yqm0000gn/T/Rtmpkg2wPL/devtools_install_f587bda3b4d/measurrr’
Error: Command failed (1)

```

So it seems like the problem is coming from the compilation of the c++ file that is generated? Here is the full output, which is also on travis ([https://travis-ci.org/wjakethompson/measurrr/builds/353599647](https://travis-ci.org/wjakethompson/measurrr/builds/353599647))

```
> devtools::document()
Updating measurrr documentation
Loading measurrr
Re-compiling measurrr
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save \
  --no-restore --quiet CMD INSTALL '/Users/jakethompson/Documents/GIT/packages/measurrr' \
  --library='/var/folders/h4/wk23d6yd4q57b_prqv6z7yqm0000gn/T//Rtmpkg2wPL/devtools_install_f587bda3b4d' \
  --no-R --no-data --no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch \
  --no-test-load --preclean 

* installing *source* package ‘measurrr’ ...
** libs
"/Library/Frameworks/R.framework/Resources/bin/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/uni-irt.stan
Wrote C++ file "stan_files/uni-irt.cc"
/usr/local/clang4/bin/clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I"../inst/include" -I"`"/Library/Frameworks/R.framework/Resources/bin/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=ignore_error -I"/Users/jakethompson/R/BH/include" -I"/Users/jakethompson/R/Rcpp/include" -I"/Users/jakethompson/R/RcppEigen/include" -I"/Users/jakethompson/R/rstan/include" -I"/Users/jakethompson/R/StanHeaders/include" -I/usr/local/include -fPIC -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c stan_files/uni-irt.cc -o stan_files/uni-irt.o
In file included from stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:20:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_args.hpp:12:
In file included from /Users/jakethompson/R/BH/include/boost/lexical_cast.hpp:32:
In file included from /Users/jakethompson/R/BH/include/boost/lexical_cast/try_lexical_convert.hpp:42:
In file included from /Users/jakethompson/R/BH/include/boost/lexical_cast/detail/converter_lexical.hpp:52:
In file included from /Users/jakethompson/R/BH/include/boost/container/container_fwd.hpp:61:
/Users/jakethompson/R/BH/include/boost/container/detail/std_fwd.hpp:27:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
BOOST_MOVE_STD_NS_BEG
^
/Users/jakethompson/R/BH/include/boost/move/detail/std_ns_begin.hpp:18:34: note: expanded from macro 'BOOST_MOVE_STD_NS_BEG'
   #define BOOST_MOVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD
                                 ^
/usr/local/clang4/bin/../include/c++/v1/__config:388:52: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_STD'
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
                                                   ^
In file included from stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:1:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Core:531:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:2:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/LU:47:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:3:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Cholesky:12:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Jacobi:29:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:3:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Cholesky:43:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/QR:17:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Householder:27:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:5:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/SVD:48:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Geometry:58:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core.hpp:14:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Dense:7:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Eigenvalues:58:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:12:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat.hpp:83:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Sparse:26:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/SparseCore:66:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:12:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat.hpp:83:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Sparse:27:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/OrderingMethods:71:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:12:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat.hpp:83:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Sparse:29:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/SparseCholesky:43:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:12:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat.hpp:83:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Sparse:32:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/SparseQR:35:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:35:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/diagnose/diagnose.hpp:10:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/test_gradients.hpp:7:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/model/log_prob_grad.hpp:4:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/rev/mat.hpp:12:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat.hpp:83:
In file included from /Users/jakethompson/R/StanHeaders/include/stan/math/prim/mat/fun/csr_extract_u.hpp:6:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/Sparse:33:
In file included from /Users/jakethompson/R/RcppEigen/include/Eigen/IterativeLinearSolvers:46:
/Users/jakethompson/R/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 stan_files/uni-irt.cc:3:
In file included from stan_files/uni-irt.hpp:18:
In file included from /Users/jakethompson/R/rstan/include/rstan/rstaninc.hpp:3:
In file included from /Users/jakethompson/R/rstan/include/rstan/stan_fit.hpp:36:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/services/optimize/bfgs.hpp:11:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/optimization/bfgs.hpp:9:
In file included from /Users/jakethompson/R/StanHeaders/include/src/stan/optimization/lbfgs_update.hpp:6:
In file included from /Users/jakethompson/R/BH/include/boost/circular_buffer.hpp:54:
In file included from /Users/jakethompson/R/BH/include/boost/circular_buffer/details.hpp:20:
In file included from /Users/jakethompson/R/BH/include/boost/move/move.hpp:30:
In file included from /Users/jakethompson/R/BH/include/boost/move/iterator.hpp:27:
/Users/jakethompson/R/BH/include/boost/move/detail/iterator_traits.hpp:29:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
BOOST_MOVE_STD_NS_BEG
^
/Users/jakethompson/R/BH/include/boost/move/detail/std_ns_begin.hpp:18:34: note: expanded from macro 'BOOST_MOVE_STD_NS_BEG'
   #define BOOST_MOVE_STD_NS_BEG _LIBCPP_BEGIN_NAMESPACE_STD
                                 ^
/usr/local/clang4/bin/../include/c++/v1/__config:388:52: note: expanded from macro '_LIBCPP_BEGIN_NAMESPACE_STD'
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE {
                                                   ^
stan_files/uni-irt.cc:5:1: error: variable has incomplete type 'void'
RCPP_MODULE(stan_fit4uni-irt_mod) {
^
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:429:10: note: expanded from macro 'RCPP_MODULE'
    void _rcpp_module_##name##_init() ; \
         ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
RCPP_MODULE(stan_fit4uni-irt_mod) {
                        ^
stan_files/uni-irt.cc:5:1: error: static declaration of '_rcpp_module_stan_fit4uni' follows non-static declaration
RCPP_MODULE(stan_fit4uni-irt_mod) {
^
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:430:25: note: expanded from macro 'RCPP_MODULE'
    static Rcpp::Module _rcpp_module_##name( # name ) ; \
                        ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:1: note: previous definition is here
/Users/jakethompson/R/Rcpp/include/Rcpp/Module.h:429:10: note: expanded from macro 'RCPP_MODULE'
    void _rcpp_module_##name##_init() ; \
         ^
<scratch space>:196:1: note: expanded from here
_rcpp_module_stan_fit4uni
^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
RCPP_MODULE(stan_fit4uni-irt_mod) {
                        ^
stan_files/uni-irt.cc:5:25: error: expected ';' after top level declarator
15 warnings and 5 errors generated.
make: *** [stan_files/uni-irt.o] Error 1
rm stan_files/uni-irt.cc
ERROR: compilation failed for package ‘measurrr’
* removing ‘/private/var/folders/h4/wk23d6yd4q57b_prqv6z7yqm0000gn/T/Rtmpkg2wPL/devtools_install_f587bda3b4d/measurrr’
Error: Command failed (1)

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [March 15, 2018, 12:57am UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562/4 "2018-03-15T00:57:25Z")

</div>

Apparently, you are not allowed to have a hyphen in a filename of a Stan program. So,

```
git mv src/stan_files/uni-irt.stan src/stan_files/uni_irt.stan

```

and change the third line `src/Makevars` and `src/Makevars.win` accordingly (you can change it to `SOURCES = $(wildcard stan_files/*.stan)` now that you are requiring GNU make to make it future proof).

It should then build but fail to load, which I believe is due to not having `@useDynLib measurrr, .registration = TRUE` in R/measurrr-package.R .

---

<div class="post-metadata">

**Author:** ![wjakethompson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wjakethompson/32/857_2.png) [@wjakethompson](https://discourse.mc-stan.org/u/wjakethompson)\
**Post date:** [March 15, 2018, 2:21am UTC](https://discourse.mc-stan.org/t/r-package-using-rstantools-fails-to-install/3562/5 "2018-03-15T02:21:03Z")

</div>

:raised\_hands:

Everything is working now! Thanks so much for your help!!
