# Error installing cmdstan

**URL:** <https://discourse.mc-stan.org/t/error-installing-cmdstan/25650>\
**Category:** CmdStan\
**Tags:** installation\
**Created:** [December 10, 2021, 4:41pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650 "2021-12-10T16:41:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdeonovic](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bdeonovic/32/10527_2.png) [@bdeonovic](https://discourse.mc-stan.org/u/bdeonovic)\
**Post date:** [December 10, 2021, 4:41pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650/1 "2021-12-10T16:41:33Z")

</div>

I’m trying to install cmdstan (Windows 10, RStudio 2021.09.1, R 4.1.2)

I installed cmdstanr from github

```
devtools::install_github("stan-dev/cmdstanr")

```

The toolchain is correctly setup to install cmdstan

```
> cmdstanr::check_cmdstan_toolchain(fix=TRUE)
The C++ toolchain required for CmdStan is setup properly!

```

I tried specifying the directory as suggested [here](https://discourse.mc-stan.org/t/cmdstan-not-installing/19183/4) but I get the following error:

```
> install_cmdstan(cores=2, dir="C:/Users/yim583")
The C++ toolchain required for CmdStan is setup properly!
* Latest CmdStan release is v2.28.2
* Installing CmdStan v2.28.2 in C:/Users/yim583/cmdstan-2.28.2
* Downloading cmdstan-2.28.2.tar.gz from GitHub...
* Download complete
* Unpacking archive...
stan/lib/stan_math/lib/benchmark_1.5.1/docs/tools.md: truncated gzip input
tar.exe: Error exit delayed from previous errors.
Error: Problem extracting tarball. Exited with return code: 1
In addition: Warning message:
In utils::untar(dest_file, exdir = dir_cmdstan, extras = "--strip-components 1") :
  ‘tar.exe -xf "C:/Users/yim583/cmdstan-2.28.2.tar.gz" -C "C:/Users/yim583/cmdstan-2.28.2" --strip-components 1’ returned error code 1

```

I also have a working `tar`

```
> system("tar.exe")
tar.exe: Must specify one of -c, -r, -t, -u, -x
[1] 1

```

---

<div class="post-metadata">

**Author:** ![WardBrian](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wardbrian/32/12078_2.png) [@WardBrian](https://discourse.mc-stan.org/u/WardBrian)\
**Post date:** [December 10, 2021, 4:55pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650/2 "2021-12-10T16:55:45Z")

</div>

Are you able to open the downloaded file in your user directory with some other tool (7zip for example)? It might be a corrupted download, but if re-running continues to have errors then I’m not so sure. @rok_cesnovar is this error familiar?

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [December 10, 2021, 5:15pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650/3 "2021-12-10T17:15:02Z")

</div>

Pozdrav Benjamin,

> [@WardBrian](#):
>
> It might be a corrupted download

I would say this is the case here. Based on `truncated gzip input`. Maybe try downloading the cmdstan tarball manually? Is AWS/Github having issues again maybe?

---

<div class="post-metadata">

**Author:** ![bdeonovic](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bdeonovic/32/10527_2.png) [@bdeonovic](https://discourse.mc-stan.org/u/bdeonovic)\
**Post date:** [December 10, 2021, 5:21pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650/4 "2021-12-10T17:21:05Z")

</div>

Hvala Rok. Where to download the tarball manually from? Is this best?  
[https://github.com/stan-dev/cmdstan/releases/download/v2.28.2/cmdstan-2.28.2.tar.gz](https://github.com/stan-dev/cmdstan/releases/download/v2.28.2/cmdstan-2.28.2.tar.gz)

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [December 10, 2021, 5:28pm UTC](https://discourse.mc-stan.org/t/error-installing-cmdstan/25650/5 "2021-12-10T17:28:09Z")

</div>

Yeah, the downloaded tar should have around 48MB. Then unzip that to a folder and point cmdstanr to it:

```
set_cmdstan_path("the/new/folder)
rebuild_cmdstan(cores = X) # set X to 4 or 2

```
