# Updating to C++17 to use rstan 2.36

**URL:** <https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328>\
**Category:** General\
**Created:** [April 21, 2025, 4:23pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328 "2025-04-21T16:23:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 4:23pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/1 "2025-04-21T16:23:03Z")

</div>

Title says it: I have the C++13 compiler but cannot figure out how to get the C++17 compiler to use rstan 2.36.

Relevant info (I think):

```no-highlight
> sessionInfo()
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base     

loaded via a namespace (and not attached):
[1] processx_3.8.6 compiler_4.4.3 R6_2.6.1 tools_4.4.3 rstudioapi_0.17.1 callr_3.7.6      
[7] ps_1.9.0 pkgbuild_1.4.7

> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running "C:/PROGRA~1/R/R-44~1.3/bin/x64/Rcmd.exe" SHLIB foo.c
using C compiler: 'gcc.exe (GCC) 13.3.0'
gcc -I"C:/PROGRA~1/R/R-44~1.3/include" -DNDEBUG -I"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c foo.c -o foo.o
gcc -shared -s -static-libgcc -o foo.dll tmp.def foo.o -LC:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-44~1.3/bin/x64 -lR
 
Your system is ready to build packages!

```

Thanks for your help :)

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [April 21, 2025, 5:12pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/2 "2025-04-21T17:12:28Z")

</div>

This is definitely confusing, but `gcc 13` means you have version 13 of the Gnu Compiler Collection, which includes a C++ compiler that is capable of building C++17 (and even [newer versions](https://en.cppreference.com/w/cpp/compiler_support)). The version numbers aren’t necessarily the same as the C++ editions they support.

So you should be fine on that front – are you getting a specific error when using RStan?

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 6:13pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/3 "2025-04-21T18:13:44Z")

</div>

Thanks so much for helping me understand this.

The code compiles and runs fine with the version of `rstan` on cran.

Also, the code checks out as well with the newest version of R:

```no-highlight
> rstan:::rstudio_stanc("stan-code-Poi-alt-2-2024.stan")
stan-code-Poi-alt-2-2024.stan is syntactically correct.

```

I am an error using the `stan_model` function. It is a big wall of black and red text, I’ve edited some of it out to hide some filepath info:

```no-highlight
> stan.mod1 <- stan_model("stan-code-Poi-alt-2-2024.stan") 
make cmd is
  make -f "C:/PROGRA~1/R/R-44~1.3/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-44~1.3/share/make/winshlib.mk" CXX='$(CXX17) $(CXX17STD)' CXXFLAGS='$(CXX17FLAGS)' CXXPICFLAGS='$(CXX17PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX17LDFLAGS)' SHLIB_LD='$(SHLIB_CXX17LD)' SHLIB="file2be865aa79f.dll" WIN=64 TCLBIN= OBJECTS="file2be865aa79f.o"

make would use
g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-44~1.3/include" -DNDEBUG -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/Rcpp/include/" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppEigen/include/" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppEigen/include/unsupported" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/BH/include" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/include/src/" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/include/" -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/redacted/AppData/Local/R/win-library/4.4/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_HAS_AUTO_PTR_ETC=0 -include "C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y -I"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c file2be865aa79f.cpp -o file2be865aa79f.o
if test "zfile2be865aa79f.o" != "z"; then \
  if test -e "file2be865aa79f-win.def"; then \
    echo g++ -shared -s -static-libgcc -o file2be865aa79f.dll file2be865aa79f-win.def file2be865aa79f.o "C:/Users/redacted/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/libs/x64" -lRcppParallel -LC:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.3/bin/x64" -lR ; \
    g++ -shared -s -static-libgcc -o file2be865aa79f.dll file2be865aa79f-win.def file2be865aa79f.o "C:/Users/redacted/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/libs/x64" -lRcppParallel -LC:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.3/bin/x64" -lR ; \
  else \
    echo EXPORTS > tmp.def; \
    nm file2be865aa79f.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^][^]*/"&"/g' >> tmp.def; \
    echo g++ -shared -s -static-libgcc -o file2be865aa79f.dll tmp.def file2be865aa79f.o "C:/Users/redacted/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/libs/x64" -lRcppParallel -LC:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.3/bin/x64" -lR ; \
    g++ -shared -s -static-libgcc -o file2be865aa79f.dll tmp.def file2be865aa79f.o "C:/Users/redacted/AppData/Local/R/win-library/4.4/rstan/lib/x64/libStanServices.a" -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64" -ltbb -L"C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/libs/x64" -lRcppParallel -LC:/Users/redacted/AppData/Local/R/win-library/4.4/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/RBuildTools/4.4/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-44~1.3/bin/x64" -lR ; \
    rm -f tmp.def; \
  fi \
fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
   Cb>&, const Eigen::Matrix<double, R1, C1>&, const Eigen::Matrix<double, Rb, Cb>&, const Eigen::Matrix<double, Cb, Cb>&) [with Ta = stan::math::var_value<double>; int Ra = -1; int Ca = -1; Tb = double; int Rb = -1; int Cb = 1]'
C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:91:0: required from 'void stan::math::internal::quad_form_vari<Ta, Ra, Ca, Tb, Rb, Cb>::chain() [with Ta = stan::math::var_value<double>; int Ra = -1; int Ca = -1; Tb = double; int Rb = -1; int Cb = 1]'
C:/Users/redacted/AppData/Local/R/win-library/4.4/StanHeaders/include/stan/math/rev/fun/quad_form.hpp:88:0: required from here
C:/Users/redacted/AppData/Local/R/win-library/4.4/RcppEigen/include/Eigen/src/Core/CoreEvaluators.h:1071:54: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits<double>::type' {aka '__m128d'} [-Wignored-attributes]
make: *** [C:/PROGRA~1/R/R-44~1.3/etc/x64/Makeconf:296: file2be865aa79f.o
Error in sink(type = "output") : invalid connection

```

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [April 21, 2025, 6:15pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/4 "2025-04-21T18:15:22Z")

</div>

At this point I’ll ask @andrjohns if he can take a look at that compiler error

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [April 21, 2025, 9:12pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/5 "2025-04-21T21:12:12Z")

</div>

> [@nelsjohnson](#):
>
> runs fine with the version of `rstan` on cran.

If you don’t need any of the special features of `rstan` that are not available in `bridgestan`, I would strongly recommend converting to `cmdstanr`, which is much easier to install than `rstan` and also keeping up with the roughly quarterly language releases.

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 10:25pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/6 "2025-04-21T22:25:58Z")

</div>

Thanks for looking into this. I am not familiar with `bridgestan`. I am specifically looking for the sum to zero vector functionality.

I am familiar with `cmndstanr` and always have issues with it. For example:

```no-highlight
> library(cmdstanr)
This is cmdstanr version 0.9.0
- CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
- CmdStan path: C:/Users/redacted/.cmdstan/cmdstan-2.36.0
- CmdStan version: 2.36.0
> stan.mod1 <- cmdstan_model("stan-code-Poi-alt-2-2024.stan")
Compiling Stan program...
INFO: Could not find files for the given pattern(s).

make[1]: /bin/sh: Permission denied

make[1]: /bin/sh: Permission denied

../tbb_2020.3/build/common.inc:81: *** Architecture not detected. Stop.
make: *** [stan/lib/stan_math/make/libraries:179: stan/lib/stan_math/lib/tbb/tbb.def] Error 2

Error: An error occured during compilation! See the message above for more information.

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [April 21, 2025, 10:36pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/7 "2025-04-21T22:36:03Z")

</div>

It looks like the same error for both `rstan` and `cmdstanr` - you don’t have permissions to use the RTools compilers. Is this a work/university PC?

Are you able to install packages from source? What output do you get from:

```r
install.packages("Rcpp", type="source")

```

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 10:39pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/8 "2025-04-21T22:39:23Z")

</div>

Thanks again so much. It is a work computer.

I get the following:

```no-highlight
> install.packages("Rcpp", type="source")
Installing package into ‘C:/Users/redcated/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_1.0.14.tar.gz'
Content type 'application/x-gzip' length 3013288 bytes (2.9 MB)
downloaded 2.9 MB

* installing *source* package 'Rcpp' ...
** package 'Rcpp' successfully unpacked and MD5 sums checked
ERROR: cannot remove earlier installation, is it in use?
* removing 'C:/Users/redacted/AppData/Local/R/win-library/4.4/Rcpp'
* restoring previous 'C:/Users/redacted/AppData/Local/R/win-library/4.4/Rcpp'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
  problem copying C:\Users\redacted\AppData\Local\R\win-library\4.4\00LOCK-Rcpp\Rcpp\libs\x64\Rcpp.dll to C:\Users\redacted\AppData\Local\R\win-library\4.4\Rcpp\libs\x64\Rcpp.dll: Permission denied
Warning in install.packages :
  installation of package ‘Rcpp’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\redacted\AppData\Local\Temp\RtmpQJs6wc\downloaded_packages’

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [April 21, 2025, 10:41pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/9 "2025-04-21T22:41:59Z")

</div>

Can you restart R/RStudio, making sure no packages/projects are loaded, and try the command again? Looks like the package was already loaded

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 10:43pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/10 "2025-04-21T22:43:25Z")

</div>

Exact same error. More infor for clarity:

```no-highlight
> sessionInfo()
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base     

loaded via a namespace (and not attached):
[1] compiler_4.4.3 tools_4.4.3 rstudioapi_0.17.1

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [April 21, 2025, 10:49pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/11 "2025-04-21T22:49:52Z")

</div>

In that case, what output do you get from:

```r
remove.packages("Rcpp")
install.packages("Rcpp", type="source")

```

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 21, 2025, 10:51pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/12 "2025-04-21T22:51:42Z")

</div>

A nice clean install.

Edit: tried compiling my stan model again, same error as in initial post. I will reply tomorrow when I am at work.

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 24, 2025, 7:10pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/13 "2025-04-24T19:10:03Z")

</div>

Hi All,

Any thoughts on where to go from here?

---

<div class="post-metadata">

**Author:** ![rosgori](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rosgori/32/3059_2.png) [@rosgori](https://discourse.mc-stan.org/u/rosgori)\
**Post date:** [April 26, 2025, 10:21pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/14 "2025-04-26T22:21:13Z")

</div>

Did you verify the installation? According to [this page](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started), the code is:

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

```

and it should be okay, in my case there is an error:

```r
Compilation ERROR, function(s)/method(s) not created!
Error en compileCode(f, code, language = language, verbose = verbose): 
  tric.hpp:22:0: required from 'double stan::mcmc::dense_e_metric<Model, BaseRNG>::T(stan::mcmc::dense_e_point&) [with Model = modele64438b1918__namespace::modele64438b1918_; BaseRNG = boost::random::mixmax_engine<17, 36, 0>]'
   22 | return 0.5 * z.p.transpose() * z.inv_e_metric_ * z.p;
C:/Users/rosgori/AppData/Local/R/win-library/4.5/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here
   21 | double T(dense_e_point& z) {
C:/Users/rosgori/AppData/Local/R/win-library/4.5/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-45~1.0/etc/x64/Makeconf:296: filee647de17426.o

```

According to [this](https://mc-stan.org/install/), I tried to install `RStan` by two methods:

1. Windows → RStan → R-Universe
2. Windows → RStan → Github (Source)

The first one shows that error; you could say that after the installation, there are errors within `RStan` and you cannot compile the Stan model. Nothing you can do here.

With the second method, there is another error!

```r
package ‘StanHeaders’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\rosgori\AppData\Local\Temp\Rtmp4Wo5WQ\downloaded_packages
── R CMD build ──────────────────────────────────────────────────────────────────────────────────────────────────
✔ checking for file 'C:\Users\rosgori\AppData\Local\Temp\Rtmp4Wo5WQ\remotes308817f82f8d\stan-dev-rstan-662ac20\rstan\rstan/DESCRIPTION' (487ms)
─ preparing 'rstan': (4s)
✔ checking DESCRIPTION meta-information ... 
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts (854ms)
─ checking for empty or unneeded directories
─ looking to see if a 'data/datalist' file should be added
─ building 'rstan_2.36.0.9000.tar.gz' (1.5s)
   
Installing package into ‘C:/Users/rosgori/AppData/Local/R/win-library/4.5’
(as ‘lib’ is unspecified)
* installing *source* package 'rstan' ...
** this is package 'rstan' version '2.36.0.9000'
** using staged installation
** libs
Error: package 'StanHeaders' 2.32.10 was found, but >= 2.36.0 is required by 'rstan'
* removing 'C:/Users/rosgori/AppData/Local/R/win-library/4.5/rstan'
Aviso:
In i.p(...) :
  installation of package ‘C:/Users/rosgori/AppData/Local/Temp/Rtmp4Wo5WQ/file3088759845d2/rstan_2.36.0.9000.tar.gz’ had non-zero exit status

```

The errors means the installer downloads `StanHeaders` 2.32.10 for `RStan` 2.36, but it needs `StanHeaders` \>= 2.36.The last version of `StanHeaders` is 2.32.10 according to [this page](https://cran.r-project.org/web/packages/StanHeaders/index.html)

I bet, just like me, you cannot use `RStan` because of those reasons, and unfortunately the installation for `RStan` is not working at this moment.

The other option is `CmdStanR`, but you said you were having problems with the installation.

---

<div class="post-metadata">

**Author:** ![nelsjohnson](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nelsjohnson/32/4746_2.png) [@nelsjohnson](https://discourse.mc-stan.org/u/nelsjohnson)\
**Post date:** [April 29, 2025, 3:40pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/15 "2025-04-29T15:40:19Z")

</div>

Thanks for looking into this!

I get different results than you with R-universe:

Nice install:

```no-highlight

> install.packages("rstan", repos = c('https://stan-dev.r-universe.dev', getOption("repos")))
Installing package into ‘C:/Users/redacted/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘StanHeaders’

trying URL 'https://stan-dev.r-universe.dev/bin/windows/contrib/4.4/StanHeaders_2.36.0.9000.zip'
Content type 'application/zip' length 3307320 bytes (3.2 MB)
downloaded 3.2 MB

trying URL 'https://stan-dev.r-universe.dev/bin/windows/contrib/4.4/rstan_2.36.0.9000.zip'
Content type 'application/zip' length 2779589 bytes (2.7 MB)
downloaded 2.7 MB

package ‘StanHeaders’ successfully unpacked and MD5 sums checked
package ‘rstan’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\redacted\AppData\Local\Temp\RtmpamI3Aj\downloaded_packages
>

```

As for the installation cannot be verified and the error message is so long than the stan forums here won’t let me post them because my reply would be about 2x or 3x the size limit :(

For the devs, any idea when the install issues others are also encountering with rstan on Github (source) and R-universe will be resolved? I might have to wait until then to figure out this issue more.

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [April 30, 2025, 4:29pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/16 "2025-04-30T16:29:26Z")

</div>

> [@rosgori](#):
>
> `Compilation ERROR, function(s)/method(s) not created!`

Unfortunately, there isn’t any meaningful content in that error message. R seems to be cutting it off, which I don’t know how to ask it not to.

> [@rosgori](#):
>
> The errors means the installer downloads `StanHeaders` 2.32.10 for `RStan` 2.36, but it needs `StanHeaders` \>= 2.36.T

I believe to install RStan from source you also must install StanHeaders from source, though the RStan installation instructions seem to neglect this

Can you try with an extra install\_github line:

```no-highlight
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "StanHeaders")
remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan")

```

---

<div class="post-metadata">

**Author:** ![rosgori](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rosgori/32/3059_2.png) [@rosgori](https://discourse.mc-stan.org/u/rosgori)\
**Post date:** [May 1, 2025, 4:02pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/17 "2025-05-01T16:02:26Z")

</div>

With those two lines, same error:

```r
Compilation ERROR, function(s)/method(s) not created!
Error en compileCode(f, code, language = language, verbose = verbose): 
  c.hpp:22:0: required from 'double stan::mcmc::dense_e_metric<Model, BaseRNG>::T(stan::mcmc::dense_e_point&) [with Model = model1b2411573bb9__namespace::model1b2411573bb9_; BaseRNG = boost::random::mixmax_engine<17, 36, 0>]'
   22 | return 0.5 * z.p.transpose() * z.inv_e_metric_ * z.p;
C:/Users/rosgori/AppData/Local/R/win-library/4.5/StanHeaders/include/src/stan/mcmc/hmc/hamiltonians/dense_e_metric.hpp:21:0: required from here
   21 | double T(dense_e_point& z) {
C:/Users/rosgori/AppData/Local/R/win-library/4.5/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-45~1.0/etc/x64/Makeconf:296: file1b244881390e.o

```

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [May 1, 2025, 4:20pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/18 "2025-05-01T16:20:57Z")

</div>

Do you get any longer output if you set `options(warning.length)` to something larger (like ~5000)?

---

<div class="post-metadata">

**Author:** ![rosgori](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rosgori/32/3059_2.png) [@rosgori](https://discourse.mc-stan.org/u/rosgori)\
**Post date:** [May 1, 2025, 4:44pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/19 "2025-05-01T16:44:39Z")

</div>

The output is very long and there is a limit of characters here, I pasted here: [error-rstan - Pastebin.com](https://pastebin.com/TCvPEMKQ)

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [May 1, 2025, 8:53pm UTC](https://discourse.mc-stan.org/t/updating-to-c-17-to-use-rstan-2-36/39328/20 "2025-05-01T20:53:32Z")

</div>

Unfortunately I’m still not spotting the root cause in that message. @andrjohns might know how to get a better one to show up
