How to install Rtools 4.4 toolchain for CmdStanR on Windows from tarball (Behind firewall)

I’ve posted here before on this subject, but things have changed somewhat since Rtools 4.2. I am trying to get CmdStanR running behind a restrictive firewall. I must always download the installer executables elsewhere and transfer them to the target system. The Rtools 4.4 installer works as expected, as does CmdStanR. The problem is that I cannot get the CmdStan toolchain installed properly.

I have downloaded rtools44-toolchain-libs-full-6335.tar.zst. check_cmdstan_toolchain(fix = TRUE) does not work, because there is no option in it to specify a local file instead of attempting a download. I tried using the Rtools Msys bash to extract the tarball using pacman, with the following results.

pacman -U "E:/rtools44-toolchain-libs-full-6335.tar"
loading packages...
error: missing package metadata in E:/rtools44-toolchain-libs-full-6335.tar
error: 'E:/rtools44-toolchain-libs-full-6335.tar': invalid or corrupted package

In case it isn’t clear, I do not know how to use pacman or bash properly. I feel as if I must be close. Can someone give me a steer please?

  • Operating System: Windows 11
  • CmdStan Version: 2.36.0
  • Compiler/Toolkit: Rtools 4.4 / mingw

If you install the development version of cmdstanr it will use the installed rtools toolchain with no additional configuration/installation needed:

# install.packages("remotes")
remotes::install_github("stan-dev/cmdstanr")
1 Like

Thank-you, that appears to have gotten closer, with the appropriate firewall workarounds. The toolchain appears to exist when checked

This is cmdstanr version 0.8.1.9000
- CmdStanR documentation and vignettes: mc-stan.org/cmdstanr
- CmdStan path: C:/Users/hunterg/.cmdstan/cmdstan-2.36.0
- CmdStan version: 2.36.0
Error in fetch(key) : 
  lazy-load database 'C:/Users/hunterg/AppData/Local/R/win-library/4.4/cmdstanr/help/cmdstanr.rdb' is corrupt
> check_cmdstan_toolchain()
The C++ toolchain required for CmdStan is setup properly!

but the test model fails to compile:

> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Compiling Stan program...
Error in `process_initialize(self, private, command, args, stdin, stdout, …`:
! Native call to `processx_exec` failed
Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
! Command 'bin/stanc.exe' not found @win/processx.c:982 (processx_exec)
Type .Last.error to see the more details.

> .Last.error
<c_error/rlib_error_3_0/rlib_error/error>
Error in `process_initialize(self, private, command, args, stdin, stdout, …`:
! Native call to `processx_exec` failed
Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
! Command 'bin/stanc.exe' not found @win/processx.c:982 (processx_exec)
---
Backtrace:
 1. cmdstanr::cmdstan_model(file)
 2. CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
 3. local initialize(...)
 4. self$compile(...)
 5. cmdstanr:::get_standalone_hpp(temp_stan_file, stancflags_standalone)
 6. withr::with_path(c(toolchain_PATH_env_var(), tbb_path()), wsl_compatible_run(command = stanc_cmd(), …
 7. base::force(code)
 8. cmdstanr:::wsl_compatible_run(command = stanc_cmd(), args = c(paste0("--o=", …
 9. base::do.call(processx::run, run_args)
10. (function (command = NULL, args = character(), error_on_status = TRUE, …
11. process$new(command, args, echo_cmd = echo_cmd, wd = wd, windows_verbatim_args = windows_verbatim_args, …
12. local initialize(...)
13. processx:::process_initialize(self, private, command, args, stdin, stdout, …
14. processx:::chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …
15. | base::withCallingHandlers(do.call(".Call", list(.NAME, ...)), error = function(e) { …
16. | base::do.call(".Call", list(.NAME, ...))
17. | base::.handleSimpleError(function (e) …
18. | local h(simpleError(msg, call))
19. | processx:::throw_error(err, parent = e)

An exhaustive search of the c drive shows that stanc.exe is not present.

I think you still need to run rebuild_cmdstan() so that cmdstan is configured/built

Ah yes, that did the trick. Thank-you!