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

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

You temporarily need

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

I’m having the same issue with brms,

I have:

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:

Failing with:

#> 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'

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

@mattansb Do the updated links in Rstan on Windows work for you?

Yes, thanks Jonah!

1 Like