# Cannot install cmdstanr on freshly installed macOS + RStudio

**URL:** <https://discourse.mc-stan.org/t/cannot-install-cmdstanr-on-freshly-installed-macos-rstudio/26736>\
**Category:** CmdStan\
**Created:** [March 10, 2022, 12:50am UTC](https://discourse.mc-stan.org/t/cannot-install-cmdstanr-on-freshly-installed-macos-rstudio/26736 "2022-03-10T00:50:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gustavo\_Lacerda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/gustavo_lacerda/32/9863_2.png) [@Gustavo\_Lacerda](https://discourse.mc-stan.org/u/Gustavo_Lacerda)\
**Post date:** [March 10, 2022, 12:50am UTC](https://discourse.mc-stan.org/t/cannot-install-cmdstanr-on-freshly-installed-macos-rstudio/26736/1 "2022-03-10T00:50:24Z")

</div>

When I try to install cmdstanr, I get this:  
`> 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/src/contrib` `:`  
` cannot open URL '` `https://mc-stan.org/r-packages/src/contrib/PACKAGES` `'`  
`Warning in install.packages :`  
` package 'cmdstanr' is not available for this version of R`

Should I believe the second warning?

Ok, so apparent I first needed to install cmdstan using conda. And now I’ve activated stan-env. `(stan-env) Gustavos-Air-5:~ gustavolacerda$ conda list cmdstan`  
`# packages in environment at /Users/gustavolacerda/opt/anaconda3/envs/stan-env:`  
`#`  
`# Name Version Build Channel`  
`cmdstan 2.29.1 h775853c_0 conda-forge`

But the original error is still there. Maybe Rstudio needs to connect to the python environment?

- R version: 4.1.2 (2021-11-01)
- Operating System: macOS Mojave 10.14.6
- CmdStan Version: 2.29.1
- Compiler/Toolkit: conda

---

<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:** [March 10, 2022, 4:51am UTC](https://discourse.mc-stan.org/t/cannot-install-cmdstanr-on-freshly-installed-macos-rstudio/26736/2 "2022-03-10T04:51:05Z")

</div>

The key error here is:

```nohighlight
cannot open URL 'https://mc-stan.org/r-packages/src/contrib/PACKAGES'

```

Which indicates that R wasn’t able to establish a network connection to the repo. Are you working behind a corporate proxy or similar that might be causing issues?

You could also test this by seeing if you can manually download the file using:

```r
download.file(url='https://mc-stan.org/r-packages/src/contrib/PACKAGES',
              destfile = file.path(tempdir(), "PACKAGES"))

```

If the `download.file` call works, then I’d suggest restarting your R session and trying the install again. If it still refuses to work, then you can just install the Github version instead:

```r
# install.packages("remotes")
remotes::install_github("stan-dev/cmdstanr")

```

---

<div class="post-metadata">

**Author:** ![peopletrees](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/peopletrees/32/4705_2.png) [@peopletrees](https://discourse.mc-stan.org/u/peopletrees)\
**Post date:** [February 13, 2026, 2:13pm UTC](https://discourse.mc-stan.org/t/cannot-install-cmdstanr-on-freshly-installed-macos-rstudio/26736/3 "2026-02-13T14:13:55Z")

</div>

I’m working in a virtual environment with no internet access except for CRAN, which is whitelisted. Is there a solution that uses CRAN?
