Trouble installing cmstanr in a GitHub Actions workflow

I maintain the stantargets R package, and the GitHub Actions workflows are having trouble installing cmdstanr. The DESCRIPTION file has Remotes: stan-dev/cmdstanr, but the workflows are trying and failing to install it from https://mc-stan.org/r-packages/bin/macosx/contrib/4.1. From Update docs · ropensci/stantargets@4f53500 · GitHub

Error: Error: Failed to install 'cmdstanr' from GitHub:
  (converted from warning) unable to access index for repository https://mc-stan.org/r-packages/bin/macosx/contrib/4.1:
  cannot open URL 'https://mc-stan.org/r-packages/bin/macosx/contrib/4.1/PACKAGES'

That’s weird, thanks for letting us know. I’m not entirely sure what’s going on but maybe it’s because this seems to be trying to install a version built with R 4.1

but I don’t think we’ve uploaded versions built with R 4.1 yet.

That said, even with R 4.1 it should be able to fall back on the version built with 4.0. For example, install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos"))) has a warning about this but then proceeds to install the version built with R 4.0 just fine (see below). It also looks like github actions is trying to install a binary version but then doesn’t try to install from source if that fails. install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos"))) also handles that correctly. So perhaps whatever happens when a package is listed in Remotes isn’t as robust as install.packages?

> install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Warning in install.packages :
  unable to access index for repository https://mc-stan.org/r-packages/bin/macosx/contrib/4.1:
  cannot open URL 'https://mc-stan.org/r-packages/bin/macosx/contrib/4.1/PACKAGES'
installing the source package ‘cmdstanr’

trying URL 'https://mc-stan.org/r-packages/src/contrib/cmdstanr_0.4.0.tar.gz'
Content type 'application/gzip' length 195914 bytes (191 KB)
==================================================
downloaded 191 KB

* installing *source* package ‘cmdstanr’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (cmdstanr)

Thanks Jonah, your response had some clues, and I remembered I had R_REMOTES_NO_ERRORS_FROM_WARNINGS: false in my GHA workflow files. So wrapping install_deps() in suppressWarnings() solved the original problem.

Now I am wondering why remotes would install from mc-stan.org. The documentation of remotes says it should install from GitHub.

Now I am wondering why remotes would install from mc-stan.org.

Could it be because the cmdstanr DESCRIPTION file has this?

Additional_repositories:
    https://mc-stan.org/r-packages/

Related: package building: install rstan from third party url from DESCRIPTION remotes · Issue #615 · r-lib/remotes · GitHub

Ok great, glad that solved it.

Yeah I think that’s probably why, but I didn’t realize that would also affect remotes.