Problem installing Stan on Windows 10, R 4.0.2, Rstudio 1.3.1

I have used Stan for a few years and have been able to install it on past machines with no isuues. I have a new computer and I installed everything new yesterday (Windows, R, Rstudio, and rstan).

Everything seemed to work fine based on the setup instructions but I got error message below when I ran the first example.

It seems there are quite a few users experiencing issues with Windows 10. If anyone experienced the same error below, what was there solution to getting a proper installation? In other words, does anyone have any suggestions on the best approach?

Error in file(con, “r”) : cannot open the connection
In addition: Warning messages:
1: In file.remove(c(unprocessed, processed)) :
cannot remove file ‘C:\Users\szuni\AppData\Local\Temp\Rtmpe04QOB\file534c5d945a2a.stan’, reason ‘No such file or directory’
2: In system(cmd, intern = !verbose) :
running command ‘C:/R-40~1.2/bin/x64/R CMD SHLIB file534c174af0.cpp 2> file534c174af0.cpp.err.txt’ had status 1
3: In file(con, “r”) :
cannot open file ‘file534c174af0.cpp.err.txt’: No such file or directory
Error in sink(type = “output”) : invalid connection

Start with

report back if you still have problems.

2 Likes

Thanks, Ben! This worked well for me, followed your steps and it came out as expected. Thanks again!

Hi,

I have a similar problem with the installation of rstan and R 4.02.
I have followed your suggestions but I still have an error message when compiling a model (see below).
This error can be obtained with the schools.stan example provided on the “RStan-Getting-Started” webpage.

Error in compileCode(f, code, language = language, verbose = verbose) :

Compilation ERROR, function(s)/method(s) not created! C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section .rdata$_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE]' has different size C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section .rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE[_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE]’ has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE]’ has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x

Error in sink(type = “output”) : incorrect connection

My sessionInfo();

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rstan_2.21.2 ggplot2_3.3.2 StanHeaders_2.21.0-6

loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.2 prettyunits_1.1.1 tools_4.0.2 packrat_0.5.0 pkgbuild_1.1.0 jsonlite_1.7.0
[9] lifecycle_0.2.0 tibble_3.0.3 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.7 cli_2.0.2 rstudioapi_0.11 parallel_4.0.2
[17] curl_4.3 loo_2.3.1 gridExtra_2.3 withr_2.2.0 dplyr_1.0.0 generics_0.0.2 vctrs_0.3.2 stats4_4.0.2
[25] grid_4.0.2 tidyselect_1.1.0 glue_1.4.1 inline_0.3.15 R6_2.4.1 processx_3.4.3 fansi_0.4.1 purrr_0.3.4
[33] callr_3.4.3 magrittr_1.5 codetools_0.2-16 matrixStats_0.56.0 scales_1.1.1 ps_1.3.3 ellipsis_0.3.1 assertthat_0.2.1
[41] colorspace_1.4-1 V8_3.2.0 RcppParallel_5.0.2 munsell_0.5.0 crayon_1.3.4

@wds15 ?

No idea. I just asked my colleague (who also recommended the march thing to drop) to try and everything samples just fine. So, @Rno, maybe you wipe out the installation and start over? Please make sure to use the dev versions as instructed in the RStan for Windows thread.

Ok, I will scrap everything, reinstall and keep you informed.
@bgoodri
@wds15

@wds15 @bgoodri

I have reinstalled

  • Rstudio (updated now to 1.3.1056)
  • Reinstalled R 4.0.2

… but cannot install the STAN dev version anymore (StanHeaders file not available)

Warning in install.packages :
cannot open URL ‘https://win-builder.r-project.org/gdaEAY9p8V7I/StanHeaders_2.21.0-6.zip’: HTTP status was ‘404 Not Found’

Do you have a new version or at least a functional link ?
Thanks

I’ve updated the links for R 3.6. The ones for R 4.0 are building.

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

Hummm, sorry, I cannot find the links.
can you send them to me ?

Forget about it … got them

@jonah @bgoodri @wds15

I still have the same error after reinstalling everything from scratch !

Error in compileCode(f, code, language = language, verbose = verbose) :

Compilation ERROR, function(s)/method(s) not created! C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section
`.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE]' has different size

C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section     `.rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE[_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE]' has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE]' has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x
Error in sink(type = "output") : incorrect connexionError in compileCode(f, code, language = language, verbose = verbose) : 
Compilation ERROR, function(s)/method(s) not created! C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section  `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt12domain_errorEE]' has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section `.rdata$_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE[_ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12domain_errorEEEE]' has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x64/libStanServices.a(stan_fit.o): duplicate section `.rdata$_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE[_ZTSN5boost16exception_detail19error_info_injectorISt14overflow_errorEE]' has different size
C:/Users/Rno/Documents/R/win-library/4.0/rstan/lib/x
Error in sink(type = "output") : incorrect connection

Here is what I have done

  • brand new installation of R 4.0.2

  • update of Rstudio to v1.3.10.56

  • installation of the CRAN version of rstan (avoid the installation of every depencies one by one). Note: I used install.packages(“rstan”, type = “source”)

  • installation of the last versions of StanHeaders and rstan

  • Run the schools.stan model (https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started)

  • Takes time to compile … then gives the error provided above

  • my MakeVars.win file is the following:

CXX14FLAGS=-O3 -mtune=native -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2
CXX11FLAGS=-O3 -mtune=corei7 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2

  • my R sessionInfo() is:

R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rstan_2.21.2 ggplot2_3.3.2 StanHeaders_2.21.0-6

loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.2 prettyunits_1.1.1 tools_4.0.2 pkgbuild_1.1.0 jsonlite_1.7.0 lifecycle_0.2.0
[9] tibble_3.0.3 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.7 cli_2.0.2 rstudioapi_0.11 curl_4.3 parallel_4.0.2
[17] loo_2.3.1 gridExtra_2.3 withr_2.2.0 vctrs_0.3.2 stats4_4.0.2 grid_4.0.2 glue_1.4.1 inline_0.3.15
[25] R6_2.4.1 processx_3.4.3 fansi_0.4.1 callr_3.4.3 magrittr_1.5 codetools_0.2-16 scales_1.1.1 ps_1.3.3
[33] ellipsis_0.3.1 matrixStats_0.56.0 assertthat_0.2.1 colorspace_1.4-1 V8_3.2.0 RcppParallel_5.0.2 munsell_0.5.0 crayon_1.3.4

Sorry it’s still not working. My knowledge of Windows is pretty limited, so I won’t be of much help here unfortunately. @bgoodri or @wds15 any ideas?

Try reinstalling Rcpp, possibly from source.

1 Like

FYI. I had the same problem and reinstalled Rcpp from source as suggested by @bgoodri and that solved it (I also reinstalled rstan from source as well just to be safe)

1 Like

I had a number of hassles getting stan working again - I haven’t used it for quite a while. Here are my suggestions - buyer beware:

## Fixing:
# I have reinstalled rstan, R, Rstudio, pkgbuild, rtools.
# I have removed makevars.win, and edited makevars to remove duplicates (eg CXX14...) and remove `-march=native`
# I have removed any paths from files or deleted the files that appeared in any startup, discovered using this: 
# install.packages("startup")
# startup::startup(debug = TRUE)
# Sys.getenv("PATH") #checking it has no superfluous rtools or rbuildtools or rtools 40 directories - only ones that are needed and work

Here is a laundry list of errors I had that are now fixed.

Error in withr::set_makevars(new, path, state, assignment = assignment) : 
  Multiple results for CXX14FLAGS found, something is wrong.FALSE
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/RBUILD~1/4.0/usr/mingw_/bin/g++' not found
WARNING: Rtools is required to build R packages, but the version of Rtools previously installed in C:/RBuildTools/4.0 has been deleted.

The only remaining error doesn’t seem to be an issue

Warning messages:
1: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  '-E' not found
1 Like

Sorry it was such a hassle but glad it’s working now!

Above steps got the schools and rats examples working.
To get my previous more complex model working (error was error-cannot-allocate-vector-of-size-17348-7-gb, I had to delete the compiled model my_model.rds, as suggested by my new best friend Elchorro here

Yes, models compiled with previous versions of rstan won’t work with subsequent versions of rstan.