# Rstan Error in sink(type = "output") : invalid connection

**URL:** <https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588>\
**Category:** RStan\
**Created:** [July 14, 2020, 1:00am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588 "2020-07-14T01:00:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saurabh\_Mishra](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/saurabh_mishra/32/8660_2.png) [@Saurabh\_Mishra](https://discourse.mc-stan.org/u/Saurabh_Mishra)\
**Post date:** [July 14, 2020, 1:00am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/1 "2020-07-14T01:00:20Z")

</div>

Error in compileCode(f, code, language = language, verbose = verbose) :  
Compilation ERROR, function(s)/method(s) not created! g++.exe: error: Files/R/R-3.6.3/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp: No such file or directory  
make: \*\*\* [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:215: file21ac217d4b6c.o] Error 1  
In addition: Warning message:  
In system(cmd, intern = !verbose) :  
running command ‘C:/PROGRA~1/R/R-36~1.3/bin/x64/R CMD SHLIB file21ac217d4b6c.cpp 2\> file21ac217d4b6c.cpp.err.txt’ had status 1  
Error in sink(type = “output”) : invalid connection

Operating System - Windows 10

> packageVersion(“StanHeaders”)  
> [1] ‘2.21.0.5’  
> packageVersion(“rstan”)  
> [1] ‘2.19.3’

I tried everything related to this error but couldn’t find solution, and also checked the file - 3.6.3/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp

Found this file at same location, please help someone

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 15, 2020, 2:26am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/2 "2020-07-15T02:26:44Z")

</div>

You temporarily need

```
install.packages(
"https://win-builder.r-project.org/5yFs1HoUI204/StanHeaders_2.21.0-6.zip",
repos = NULL, type = "win.binary"
)

```

---

<div class="post-metadata">

**Author:** ![mattansb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mattansb/32/20280_2.png) [@mattansb](https://discourse.mc-stan.org/u/mattansb)\
**Post date:** [July 22, 2020, 10:30am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/3 "2020-07-22T10:30:13Z")

</div>

I’m having the same issue with `brms`,

I have:

```R
packageVersion("brms")
#> [1] ‘2.13.3’
packageVersion("rstan")
#> [1] ‘2.21.1’
packageVersion("StanHeaders")
#> [1] ‘2.21.0.5’

```

I was unable to run this:

> [@bgoodri](#):
>
> ```no-highlight
> install.packages(
> "https://win-builder.r-project.org/5yFs1HoUI204/StanHeaders_2.21.0-6.zip",
> repos = NULL, type = "win.binary"
> )
> 
> ```

Failing with:

```no-highlight
#> trying URL 'https://win-builder.r-project.org/5yFs1HoUI204/StanHeaders_2.21.0-6.zip'
#> Warning in install.packages :
#> cannot open URL 'https://win-builder.r-project.org/5yFs1HoUI204/StanHeaders_2.21.0-6.zip': HTTP status was '404 Not Found'
#> Error in download.file(p, destfile, method, mode = "wb", ...) : 
#> cannot open URL 'https://win-builder.r-project.org/5yFs1HoUI204/StanHeaders_2.21.0-6.zip'

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [July 22, 2020, 2:50pm UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/4 "2020-07-22T14:50:32Z")

</div>

We can update the StanHeaders but unfortunately the Makevars handling in rstan is messed up right now.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [July 23, 2020, 2:18am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/5 "2020-07-23T02:18:59Z")

</div>

@mattansb Do the updated links in [Rstan on Windows](https://discourse.mc-stan.org/t/rstan-on-windows/16673) work for you?

---

<div class="post-metadata">

**Author:** ![mattansb](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mattansb/32/20280_2.png) [@mattansb](https://discourse.mc-stan.org/u/mattansb)\
**Post date:** [July 23, 2020, 6:58am UTC](https://discourse.mc-stan.org/t/rstan-error-in-sink-type-output-invalid-connection/16588/6 "2020-07-23T06:58:48Z")

</div>

Yes, thanks Jonah!
