Installing development version of rstan on a stand-alone windows 10 machine

I’m running R 4.2 on a windows 10 machine with rtools42 installed. I’ve seen that the version of rstan on CRAN is incompatible, and that I need to install the development version. The catch is that the machine running R is on an isolated network and cannot access github. I need to move everything over via external hard drive, so any solution that requires direct access to CRAN, github, etc. will not work.

I have successfully installed StanHeaders as follows:

  • Download the rstan, math, and stan repositories from github as .zip files
  • Move these files to the machine of interest and unzip them
  • Move the package contents from the math and stan repositories into rstan-develop/StanHeaders/inst/include/[upstream or mathlib]
  • install.packages("path/to/rstan", type = 'source', repos = NULL, INSTALL_opts = '--preclean')

This was inspired by the install-github function included in the StanHeaders folder. I suspect I just manually did a few things that most would have let git2r take care of.

Now I need to actually install rstan. Unfortunately, I’m getting “compilation failed”/non-zero exist status messages and I’m not sure why. (If I need to copy some of the compiler output across machines I can, but it’s not quite as easy for me as it would be in normal situations.)

Running install.packages("./rstan", type = 'source', repos = NULL), I see

make: *** [C:/PROGRA~1/R/R-42~1.1/etc/x64/Makeconf:260: stan_fit.o] Error 1

Are there other packages that I need to provide the compiler access to in order to perform this install?
I’ve looked at install.R (hoping for a similar solution to what I did for StanHeaders).
I have BH 1.78.0-0, inline 0.3.19, and Rcpp 1.0.8.3 installed and I can compile other Rcpp functions without issue.

Although I’m aware it’s a solution, I’m not interested in downgrading R to 4.0.x - I’ve made the switch from %>% to |> so my code is no longer compatible with 4.0 and the package collection on this machine is all 4.2, not 4.0.

The simplest approach is going to be downloading the R package binaries from the development repos and then copying them to the machine of interest to install.

The package binaries can be found in the r-packages github repo here: r-packages/bin/windows/contrib/4.2 at gh-pages · stan-dev/r-packages · GitHub

For this, you should also uninstall the Github Stanheaders that you’ve installed, and replace it with the binary from above