Install_cmdstan() fails with error: "GitHub download of release list failed"

I remote into a Windows virtual machine to do my work in R and Stan. My IT folks are trying to install CmdStan using cmdstanr::install_cmdstan() on the virtual machine and getting the following error: “Error: GitHub download of release list failed.” Here’s the code they ran (from the R GUI), along with the output:

install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

library(cmdstanr)
> This is cmdstanr version 0.4.0
> - Online documentation and vignettes at mc-stan.org/cmdstanr
> - Use set_cmdstan_path() to set the path to CmdStan
> - Use install_cmdstan() to install CmdStan
install_cmdstan()
> Error:
> RTools installation found but PATH was not properly set.
> Run check_cmdstan_toolchain(fix = TRUE) to fix the issue.
check_cmdstan_toolchain(fix = TRUE)
> Installing mingw32-make and writing RTools path to ~/.Renviron ...
> The C++ toolchain required for CmdStan is setup properly!
install_cmdstan()
> The C++ toolchain required for CmdStan is setup properly!
> Error: GitHub download of release list failed.

My local computer is a Mac and I’m not that familiar with issues that come up with Windows CmdStan installations. Searching the web and this forum for the error message didn’t turn up a solution.

The Windows virtual machine normally can’t access any website outside our firewall except the RStudio CRAN mirror, but IT opens limited outside access when they need to install new or updated software. Is it possible that R can’t access some necessary files at mc-stan.org (or elsewhere)?

Here’s some info on the Windows virtual machine:

  • Operating system: Windows Server 2016 Standard Version 10.0.14393 Build 14393.
  • R version: 4.1.1.
  • Rtools version: 4.0.

If there’s additional information that would be helpful, please let me know and I will add it.

It looks like there are firewall issues for R connecting to github, rather than a system/R configuration issue

If your IT department isn’t able to open access for the installation, then your other option is to manually download and setup cmdstan, and then use set_cmdstan_path in cmdstanr to point to it

2 Likes

You can also unpack cmdstan in the ~/.cmdstan/cmdstan-version (for example cmdstan-2.28.0) folder and it will get picked up automatically, without having to use the set_cmdstan_path function.

2 Likes

Thanks @andrjohns and @rok_cesnovar for your suggestions.

I’m now having the same issue on my personal Mac laptop. Last week, I installed CmdStan 2.28.0 without any issues by running install_cmdstan(). When I read that version 2.28.1 had been released and that it fixed a bug in 2.28.0, I tried to install 2.28.1 and got the following:

> library(cmdstanr)
This is cmdstanr version 0.4.0
- Online documentation and vignettes at mc-stan.org/cmdstanr
- CmdStan path set to: /Users/js/.cmdstanr/cmdstan-2.28.0
- Use set_cmdstan_path() to change the path

> install_cmdstan()
The C++ toolchain required for CmdStan is setup properly!
Error: GitHub download of release list failed.

I ran this while on my home network, so there shouldn’t be any special firewall issues. Furthermore, the installation worked without error last week when I installed version 2.28.0.

Based on your suggestions above, I tried a local installation by opening Terminal and running:

git clone https://github.com/stan-dev/cmdstan.git --recursive
cd cmdstan
make build

That worked. However, I’d like to resolve the issue that’s causing the “Error: GitHub download of release list failed” error. Any ideas about what could be going on and how to fix it?

While this is fine at this moment, when the state of the develop branch is not that different from the release, I would advise you to
download the release tarball and untar it: Release v2.28.1 (21 October 2021) · stan-dev/cmdstan · GitHub

The tar.gz file without the specfied OS and architecture is the one you want if you are on a x86 system.

This is the code that runs to obtain the release list:

# download with retries and pauses
download_with_retries <- function(download_url,
                                  destination_file,
                                  retries = 5,
                                  pause_sec = 5,
                                  quiet = TRUE) {

    download_rc <- 1
    while (retries > 0 && download_rc != 0) {
      try(
        suppressWarnings(
          download_rc <- utils::download.file(url = download_url,
                                            destfile = destination_file,
                                            quiet = quiet,
                                            headers = github_auth_token())
        ),
        silent = TRUE
      )
      if (download_rc != 0) {
        Sys.sleep(pause_sec)
      }
      retries <- retries - 1
    }
    if (download_rc == 0) {
      TRUE
    } else {
      FALSE
    }
}

dest_file <- tempfile(pattern = "releases-", fileext = ".json")
download_url <- "https://api.github.com/repos/stan-dev/cmdstan/releases/latest"
release_list_downloaded <- download_with_retries(download_url, dest_file)
if (!release_list_downloaded) {
    stop("GitHub download of release list failed.", call. = FALSE)
}

If possible step through it and let us know if there is an issue on our side.

2 Likes

The install is failing at github_auth_token(). I had to update my Github personal access token a few days ago, but forgot to update GITHUB_PAT in my .Renviron file (facepalm). Once I updated the token, the install on my Mac proceeded without a problem. The install on the virtual Windows machine probably failed for the same reason. I will have IT set up a Github access token for the virtual machine.

Maybe it would make sense to modify the error message in latest_released_version() to be a bit more informative about what to check in order to diagnose and fix the error (e.g., information about adding a Github access token to .Renviron).

Thanks for your help!

2 Likes

Thank you very much for debugging. Seems like an edge case we should handle yes.

I think the most common causes for this error to show up are that the user either does not have internet access, has firewall issues or restrictions, or has made too many request to Github in the last X hours (not sure what the exact limit is).

I may be wrong, but I would guess that most user dont use the GITHUB_PAT environment variable so maybe we add that suggestion only if a environment variable GITHUB_PAT is found?

Though if my assumption is wrong and please correct me anyone thinks it is, we could suggest it always.

1 Like

Hi all,
I just wanted to mention that I got the same error after updating to R 4.1.2 and following the installation instructions on the CmdStan page. And updating GITHUB_PAT with a new token did solve the issue, so thanks! This is the only place where I found the solution.

thanks - troubleshooting install failures is an evergreen problem and your feedback helps us keep on top of this issue.

ideas/suggestions on a good set of troubleshooting tips and FAQs welcome.
also, note the recent conda-forge builds: Supporting CmdStan installation via conda - #16 by WardBrian