New User Issues [RESOLVED]

Hey all, I am attempting to work with a new package in R, ‘hbayesdm’, which is dependent on RStan, and I am having a hard time getting this configured properly. I’ve tried following the installation instructions multiple times now, as well as troubleshooting steps found in other threads here with no luck. When I try to run:

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

I end up getting this error:

Error in compileCode(f, code, language = language, verbose = verbose) : 
  C:/Users/natha/AppData/Local/R/win-library/4.4/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:22:0:   required from 'double stan::mcmc::dense_e_metric<Model, BaseRNG>::T(stan::mcmc::dense_e_point&) [with Model = model5b507c0c6a97__namespace::model5b507c0c6a97_; BaseRNG = boost::random::mixmax_engine<17, 36, 0>]'C:/Users/natha/AppData/Local/R/win-library/4.4/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0:   required from hereC:/Users/natha/AppData/Local/R/win-library/4.4/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:654:74: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]  654 |   return internal::first_aligned<int(unpacket_traits<DefaultPacketType>::alignment),Derived>(m);      |                                                                          ^~~~~~~~~make: *** [C:/PROGRA~1/R/R-44~1.0/etc/x64/Makeconf:296: file5b507675690c.o] E
  • Operating System: Windows 11 Pro
  • RStan Version: 2.32.6
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))):
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'C:\Users\natha\OneDrive\Documents/.R/Makevars': No such file or directory
  • Output of devtools::session_info("rstan"):
Error in loadNamespace(x) : there is no package called ‘devtools’

Any assistance would be greatly appreciated!!!

I was actually able to get this issue sorted out shortly after I created this thread. For anyone else experiencing similar issues, here are the steps I took to solve it, courtesy of ChatGPT:

Create or update the .R/Makevars file in the home directory.

  1. Open command prompt.
  2. Create or edit the .R/Makevars file in home directory.

Add the following lines to the .R/Makevars file:

CXX14FLAGS=-O3 -march=native -mtune=native

Verify the toolchain configuration by running the following command in R:

pkgbuild::check_build_tools(debug = TRUE)

After setting up the .R/Makevars file and ensuring the toolchain is correctly configured, run the example again:

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