Problem running rstan with R 4.0.2

Hello,

Yesterday, I reinstalled R, RStudio and RTools (rtools40) after having some issues with installing packages.

I had previously been working with older versions of R and RStudio. I was able to reinstall all the packages I had before without error messages, including “rstan”. However, when using stan() on a model (and data) that worked perfectly fine before, I now get a warning message:

    Warning message:
    In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
      'C:/PROGRA~1/rtools40/usr/mingw_/bin/g++' not found

The model still seems to run as before but slower.

I have read a bunch of threads about changing the entries in Makevars.win, but I couldn’t get it to work, so I’m starting from scratch and reinstalled everything. The above message is from the fresh reinstall with nothing done to it, not even the configuration of the C++ toolchain, as suggested in the “Getting Started” section.

My first question is if I should even run the configuration of the C++ chain if it’s optional and might cause other problems.
My second question is whether this warning message is a problem at all if the model otherwise seems to work (slower, but works).

I would really appreciate some help and, because I’m not familiar at all with theses issues, I would really appreciate for any potential answer to be explained as if I’m stupid and don’t know anything :) (it will save everyone time).

Here is more information (sorry for the French in the messages):

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

    Matrix products: default

    Random number generation:
     RNG:     Mersenne-Twister 
     Normal:  Inversion 
     Sample:  Rounding 
     
    locale:
    [1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
    [5] LC_TIME=French_France.1252    

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

    other attached packages:
     [1] ghibli_0.3.2         fitdistrplus_1.1-1   survival_3.1-12      rstanarm_2.21.1      Rcpp_1.0.5           arm_1.11-2          
     [7] lme4_1.1-23          Matrix_1.2-18        MASS_7.3-51.6        reshape2_1.4.4       tidyr_1.1.1          dplyr_1.0.1         
    [13] shinystan_2.5.0      shiny_1.5.0          rstan_2.21.2         ggplot2_3.3.2        StanHeaders_2.21.0-5

    loaded via a namespace (and not attached):
      [1] minqa_1.2.4         colorspace_1.4-1    ellipsis_0.3.1      colorRamps_2.3      ggridges_0.5.2      rsconnect_0.8.16   
      [7] htmlTable_2.0.1     markdown_1.1        base64enc_0.1-3     rstudioapi_0.11     farver_2.0.3        DT_0.14            
     [13] fansi_0.4.1         codetools_0.2-16    splines_4.0.2       knitr_1.29          shinythemes_1.1.2   bayesplot_1.7.2    
     [19] Formula_1.2-3       jsonlite_1.7.0      nloptr_1.2.2.2      cluster_2.1.0       png_0.1-7           compiler_4.0.2     
     [25] backports_1.1.8     assertthat_0.2.1    fastmap_1.0.1       cli_2.0.2           later_1.1.0.1       acepack_1.4.1      
     [31] htmltools_0.5.0     prettyunits_1.1.1   tools_4.0.2         igraph_1.2.5        coda_0.19-3         gtable_0.3.0       
     [37] glue_1.4.1          V8_3.2.0            vctrs_0.3.2         nlme_3.1-148        crosstalk_1.1.0.1   xfun_0.16          
     [43] stringr_1.4.0       ps_1.3.3            mime_0.9            miniUI_0.1.1.1      lifecycle_0.2.0     gtools_3.8.2       
     [49] statmod_1.4.34      zoo_1.8-8           scales_1.1.1        colourpicker_1.0    promises_1.1.1      parallel_4.0.2     
     [55] inline_0.3.15       RColorBrewer_1.1-2  prismatic_0.2.0     yaml_2.2.1          curl_4.3            gridExtra_2.3      
     [61] loo_2.3.1           rpart_4.1-15        latticeExtra_0.6-29 stringi_1.4.6       dygraphs_1.1.1.6    checkmate_2.0.0    
     [67] boot_1.3-25         pkgbuild_1.1.0      rlang_0.4.7         pkgconfig_2.0.3     matrixStats_0.56.0  lattice_0.20-41    
     [73] purrr_0.3.4         labeling_0.3        rstantools_2.1.1    htmlwidgets_1.5.1   processx_3.4.3      tidyselect_1.1.0   
     [79] plyr_1.8.6          magrittr_1.5        R6_2.4.1            generics_0.0.2      Hmisc_4.4-0         pillar_1.4.6       
     [85] foreign_0.8-80      withr_2.2.0         xts_0.12-0          abind_1.4-5         nnet_7.3-14         tibble_3.0.3       
     [91] crayon_1.3.4        jpeg_0.1-8.1        grid_4.0.2          data.table_1.13.0   callr_3.4.3         threejs_0.3.3      
     [97] digest_0.6.25       xtable_1.8-4        httpuv_1.5.4        signal_0.7-6        RcppParallel_5.0.2  stats4_4.0.2       
    [103] munsell_0.5.0       shinyjs_1.1        


    > writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
    Error in file(con, "r") : impossible d'ouvrir la connexion
    De plus : Warning message:
    In file(con, "r") :
      impossible d'ouvrir le fichier 'C:\Users\Antoine\Documents/.R/Makevars' : No such file or directory
    > devtools::session_info("rstan")
    Error in loadNamespace(name) : 
      aucun package nommé ‘devtools’ n'est trouvé

Thank you very much for any help.

Hi @Antoine welcome to the Stan forums and sorry you’re running into this issue.

I’m not sure, @bgoodri @stevebronder? I think it would cause problems but @stevebronder made a PR recently that should avoid those problems if I understand correctly. The RStan Getting Started page really needs to be updated but I don’t know the current situation for Windows well enough to do it.

Can you try adding just this one line

CXX14FLAGS=-O3 -mtune=native

to your Makevars.win file and see if that improves the speed? If it does I think you can safely ignore that warning message (I don’t know what’s up with that warning but maybe @bgoodri or @stevebronder do.)

1 Like

Dear Jonah,

Thank your very much for your reply.

The thing is that since I removed everything and reinstalled everything, I can’t find the Makevars.win file anymore.
I found it under C:/User/Antoine/Documents/.R/ before, but now there is no such “.R” folder anymore and I can’t see a Makevars.win file:

    > writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
        Error in file(con, "r") : impossible d'ouvrir la connexion
        De plus : Warning message:
        In file(con, "r") :
          impossible d'ouvrir le fichier 'C:\Users\Antoine\Documents/.R/Makevars' : No such file or directory

All of these lines do not return anything:


    > file.edit("~/.R/Makevars.win")
    > file.edit("~/.R/Makevars")
    > file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars.win"))

Do you have any idea where the Makevars.win file could be otherwise? Like I said, I can’t find an “.R” folder. I only have a simple “R” folder in C:/User/Antoine/Documents/ but that one only contains a “win-library” folder with all the packages I downloaded. Maybe I misunderstood where the Makevars.win file should be when reading previous threads, but like I said, I’m not familiar at all with anything I’m doing here…

Cheers

What happens if you call withr::makevars_user()? Odd you can’ find a .R folder

2 Likes

Hi Steve,

Here is what I get:

> withr::makevars_user()
character(0)

Thanks for your help

Ok I think it just doesn’t exist anymore, which is OK. This code should create the directory and file if it doesn’t exist and add the one line I recommended:

dir <- file.path(Sys.getenv("HOME"), ".R")
if (!dir.exists(dir)) {
  dir.create(dir)
  cat("CXX14FLAGS=-O3 -mtune=native", file = file.path(dir, "Makevars.win"))
}

If you run that and then

file.edit(file.path(dir, "Makevars.win"))

does it now show the file with

CXX14FLAGS=-O3 -mtune=native

as the only line?

2 Likes

Yes, now it shows the file. It has a single line with “CXX14FLAGS=-O3 -mtune=native”.

I re-ran the stan() call and it doesn’t seem like it got much faster. It is still much longer than it was before the R updates.

However, I now get 2 more warnings in adition to the first one:

Warning messages:
1: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/PROGRA~1/rtools40/usr/mingw_/bin/g++' not found
2: In readLines(file.path(makevar_files)) :
  ligne finale incomplète trouvée dans 'C:/Users/Antoine/Documents/.R/Makevars.win'
3: In readLines(old_path) :
  ligne finale incomplète trouvée dans 'C:/Users/Antoine/Documents/.R/Makevars.win'

The phrase “ligne finale incomplète trouvée dans …” means “final incomplete line found in …”.

Now I also re-checked the path mentioned in the 1st warning (C:/PROGRA~1/rtools40/usr/mingw_/) and I don’t even have a “mingw_” folder. I only have a “mingw32” and a “mingw64”. This was already the case before my last reinstall, when I went through a few forum threads to find solutions and tried to apply the Makevars.win modifications suggested.

I’m not sure about the other warning, but I think this one just means that there’s no empty line at the end of the Stan program. I think that warning actually comes from R and not Stan. Safe to ignore, or you can add a blank line at the end of your Stan file to get rid of the message.

Sorry for the hassle! Another option is to use our new CmdStanR interface for R, which should be a bit faster and it doesn’t care about Makevars.win (so that’s nice too). Here are a few useful links

1 Like

The “final line incomplete” message refers to Makevars.win here, though, not the Stan file. I have had this warning for the Stan file before and I fixed that already in the model file.

Thank you for the links, I will check it out.

Simply adding an empty line to the Makevars.win file got rid of the message about the incomplete final line, so nevermind that!

I have tried installing CmdStanR and ran into a problem while following the instructions in this link.

I added

C:\Program Files\rtools40\usr\bin
C:\Program Files\rtools40\mingw64

to the PATH and tried running

pacman -Sy mingw-w64-x86_64-make

in rtools bash.

I get errors saying (if I translate again)
“the update of mingw32 failed (locking of the data base is impossible)”
then the same error for mingw64.
and the 3rd error says “Synchronisation of all data bases failed”

Could this have something to do with the space in “Program Files”? My French mashine called it “Programmes” in the file explorer and replaces that name with “Program Files” when I copy the full path.

The installation of CmdStanR failed at the install_cmdstan() level when following the “Getting started” instructions (but library(cmdstanr) worked).
Here is the error message:

> install_cmdstan(cores = 2,overwrite=T)
* Latest CmdStan release is v2.24.0
* Installing CmdStan v2.24.0 in C:\Users\Antoine\Documents/.cmdstanr/cmdstan-2.24.0
* Downloading cmdstan-2.24.0.tar.gz from GitHub...
* Removing the existing installation of CmdStan...
* Download complete
* Unpacking archive...
* Building CmdStan binaries...
Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
  Command 'mingw32-make.exe' not found @win/processx.c:994 (processx_exec)
Type .Last.error.trace to see where the error occured

Thanks for any tips you can give me, I appreciate it because I’m totally inexperienced with this.

@rok_cesnovar Any ideas about this CmdStanR windows problem?

Can you run

pacman -Syu mingw-w64-x86_64-make

notice the added u

2 Likes

If that fails try running RTools bash as administrator.

This is the relevant issue: https://github.com/msys2/MSYS2-packages/issues/1298

1 Like

Hi,
Thanks for your help.

I ran

pacman -Syu mingw-w64-x86_64-make

as admin and things have been downloaded and installed without error, it seems.

However, when checking “g++ --version” and “mingw32 --version” in a terminal (as admin and non-admin), it tells me the command is not recognised, so I don’t know if it worked or not. “bash --version” works.

After that, I opened RStudio and re-ran the CmdStanR installation to try it out and I still have the error:

    >install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
    Installing package into ‘C:/Users/Antoine/Documents/R/win-library/4.0’
    (as ‘lib’ is unspecified)

      There is a binary version available but the source version is later:
                 binary source needs_compilation
    cmdstanr 0.0.0.9008  0.1.1             FALSE

    installing the source package ‘cmdstanr’

    essai de l'URL 'https://mc-stan.org/r-packages/src/contrib/cmdstanr_0.1.1.tar.gz'
    Content type 'application/gzip' length 268716 bytes (262 KB)
    downloaded 262 KB

    * installing *source* package 'cmdstanr' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
      converting help for package 'cmdstanr'
        finding HTML links ... fini
        CmdStanGQ                               html  
        CmdStanMCMC                             html  
        CmdStanMLE                              html  
        CmdStanModel                            html  
        CmdStanVB                               html  
        cmdstan_default_install_path            html  
        cmdstan_default_path                    html  
        cmdstan_model                           html  
        cmdstanr-package                        html  
        cmdstanr_example                        html  
        eng_cmdstan                             html  
        fit-method-cmdstan_summary              html  
        fit-method-draws                        html  
        fit-method-init                         html  
        fit-method-inv_metric                   html  
        fit-method-lp                           html  
        fit-method-metadata                     html  
        fit-method-mle                          html  
        fit-method-output                       html  
        fit-method-sampler_diagnostics          html  
        fit-method-save_object                  html  
        fit-method-save_output_files            html  
        fit-method-summary                      html  
        fit-method-time                         html  
        install_cmdstan                         html  
        model-method-compile                    html  
        model-method-generate-quantities        html  
        model-method-optimize                   html  
        model-method-sample                     html  
        model-method-variational                html  
        read_cmdstan_csv                        html  
        read_sample_csv                         html  
        register_knitr_engine                   html  
        set_cmdstan_path                        html  
        stan_threads                            html  
        write_stan_json                         html  
        write_stan_tempfile                     html  
    *** copying figures
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (cmdstanr)

    The downloaded source packages are in
    	‘C:\Users\Antoine\AppData\Local\Temp\Rtmpq4bD6u\downloaded_packages’
    > library(cmdstanr)
    This is cmdstanr version 0.1.1
    - Online documentation and vignettes at mc-stan.org/cmdstanr
    - CmdStan path set to: C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0
    - Use set_cmdstan_path() to change the path
    > library(posterior)
    This is posterior version 0.1.2
    > library(bayesplot)
    This is bayesplot version 1.7.2
    - Online documentation and vignettes at mc-stan.org/bayesplot
    - bayesplot theme set to bayesplot::theme_default()
       * Does _not_ affect other ggplot2 plots
       * See ?bayesplot_theme_set for details on theme setting

    Attachement du package : ‘bayesplot’

    The following object is masked from ‘package:posterior’:

        rhat

    > color_scheme_set("brightblue")
    > install_cmdstan(cores = 2)
    * Latest CmdStan release is v2.24.0
    * Installing CmdStan v2.24.0 in C:\Users\Antoine\Documents/.cmdstanr/cmdstan-2.24.0
    * Downloading cmdstan-2.24.0.tar.gz from GitHub...
    Warning message:
    An installation already exists at C:\Users\Antoine\Documents/.cmdstanr/cmdstan-2.24.0. Please remove or rename the installation folder or set overwrite=TRUE. 
    > install_cmdstan(cores = 2,overwrite=T)
    * Latest CmdStan release is v2.24.0
    * Installing CmdStan v2.24.0 in C:\Users\Antoine\Documents/.cmdstanr/cmdstan-2.24.0
    * Downloading cmdstan-2.24.0.tar.gz from GitHub...
    * Removing the existing installation of CmdStan...
    * Download complete
    * Unpacking archive...
    * Building CmdStan binaries...
    Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
      Command 'mingw32-make.exe' not found @win/processx.c:994 (processx_exec)
    Type .Last.error.trace to see where the error occured
    > 

Ok, that seems like the path is not set. Can you check if the paths you listed above are actually where rtools is instaled.

C:\Program Files\rtools40\usr\bin
C:\Program Files\rtools40\mingw64

The default location is usually c:\rtools40\

1 Like

Yes, those paths are correct and they are what I put in PATH.
When installing rtools40, I did install it in “Program Files” because that where I have all my other stuff.
Maybe I should just reinstall it and keep all defaults?
Cheers

That should not be a problem. Just wanted to double check.

Oh, the second one should be:

C:\Program Files\rtools40\mingw64\bin

That is the location of g++.exe and mingw32-make.exe.

1 Like

Well, I feel very very stupid…

I fixed that and re-did the whole procedure and it seems to have worked up to the point when I run install_cmdstan(cores=2,overwrite=T), which now gives me a new error:

    devtools::install_github("stan-dev/cmdstanr")
    Downloading GitHub repo stan-dev/cmdstanr@HEAD
    These packages have more recent versions available.
    It is recommended to update all of them.
    Which would you like to update?

    1: All                                       
    2: CRAN packages only                        
    3: None                                      
    4: posterior (0.1.2 -> af3bfa094...) [GitHub]

    Enter one or more numbers, or an empty line to skip updates:1
    posterior (0.1.2 -> af3bfa094...) [GitHub]
    bit       (NA    -> 4.0.4       ) [CRAN]
    Installing 1 packages: bit
    Installing package into ‘C:/Users/Antoine/Documents/R/win-library/4.0’
    (as ‘lib’ is unspecified)
    essai de l'URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/bit_4.0.4.zip'
    Content type 'application/zip' length 636521 bytes (621 KB)
    downloaded 621 KB

    package ‘bit’ successfully unpacked and MD5 sums checked

    The downloaded binary packages are in
    	C:\Users\Antoine\AppData\Local\Temp\RtmpeswAII\downloaded_packages
    Downloading GitHub repo stan-dev/posterior@HEAD
    √  checking for file 'C:\Users\Antoine\AppData\Local\Temp\RtmpeswAII\remotes128861e94ad2\stan-dev-posterior-af3bfa0/DESCRIPTION' (491ms)
    -  preparing 'posterior': (1.1s)
    √  checking DESCRIPTION meta-information ... 
    -  checking for LF line-endings in source and make files and shell scripts (623ms)
    -  checking for empty or unneeded directories
    -  building 'posterior_0.1.2.tar.gz'
       
    Installing package into ‘C:/Users/Antoine/Documents/R/win-library/4.0’
    (as ‘lib’ is unspecified)
    * installing *source* package 'posterior' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
      converting help for package 'posterior'
        finding HTML links ... fini
        autocorrelation                         html  
        autocovariance                          html  
        bind_draws                              html  
        dot-ess                                 html  
        dot-rhat                                html  
        draws-index                             html  
        draws                                   html  
        draws_array                             html  
        draws_df                                html  
        draws_list                              html  
        draws_matrix                            html  
        draws_summary                           html  
        ess_basic                               html  
        ess_bulk                                html  
        ess_mean                                html  
        ess_quantile                            html  
        ess_sd                                  html  
        ess_tail                                html  
        example_draws                           html  
        extract_variable                        html  
        extract_variable_matrix                 html  
        fold_draws                              html  
        mcse_mean                               html  
        mcse_quantile                           html  
        mcse_sd                                 html  
        merge_chains                            html  
        mutate_variables                        html  
        order_draws                             html  
        posterior-package                       html  
        print.draws_array                       html  
        print.draws_df                          html  
        print.draws_list                        html  
        print.draws_matrix                      html  
        quantile2                               html  
        r_scale                                 html  
        rename_variables                        html  
        repair_draws                            html  
        resample_draws                          html  
        rhat                                    html  
        rhat_basic                              html  
        split_chains                            html  
        subset_draws                            html  
        thin_draws                              html  
        u_scale                                 html  
        weight_draws                            html  
        weights.draws                           html  
        z_scale                                 html  
    *** copying figures
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (posterior)
    √  checking for file 'C:\Users\Antoine\AppData\Local\Temp\RtmpeswAII\remotes128874183c30\stan-dev-cmdstanr-39e5f96/DESCRIPTION' (358ms)
    -  preparing 'cmdstanr': (1.7s)
    √  checking DESCRIPTION meta-information ... 
    -  checking for LF line-endings in source and make files and shell scripts (570ms)
    -  checking for empty or unneeded directories
    -  building 'cmdstanr_0.1.1.tar.gz'
       
    Installing package into ‘C:/Users/Antoine/Documents/R/win-library/4.0’
    (as ‘lib’ is unspecified)
    * installing *source* package 'cmdstanr' ...
    ** using staged installation
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
      converting help for package 'cmdstanr'
        finding HTML links ... fini
        CmdStanGQ                               html  
        CmdStanMCMC                             html  
        CmdStanMLE                              html  
        CmdStanModel                            html  
        CmdStanVB                               html  
        cmdstan_default_install_path            html  
        cmdstan_default_path                    html  
        cmdstan_model                           html  
        cmdstanr-package                        html  
        cmdstanr_example                        html  
        eng_cmdstan                             html  
        fit-method-cmdstan_summary              html  
        fit-method-draws                        html  
        fit-method-init                         html  
        fit-method-inv_metric                   html  
        fit-method-lp                           html  
        fit-method-metadata                     html  
        fit-method-mle                          html  
        fit-method-output                       html  
        fit-method-sampler_diagnostics          html  
        fit-method-save_object                  html  
        fit-method-save_output_files            html  
        fit-method-summary                      html  
        fit-method-time                         html  
        install_cmdstan                         html  
        model-method-compile                    html  
        model-method-generate-quantities        html  
        model-method-optimize                   html  
        model-method-sample                     html  
        model-method-variational                html  
        read_cmdstan_csv                        html  
        read_sample_csv                         html  
        register_knitr_engine                   html  
        set_cmdstan_path                        html  
        stan_threads                            html  
        write_stan_json                         html  
        write_stan_tempfile                     html  
    *** copying figures
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
    * DONE (cmdstanr)
    > library(cmdstanr)
    This is cmdstanr version 0.1.1
    - Online documentation and vignettes at mc-stan.org/cmdstanr
    - CmdStan path set to: C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0
    - Use set_cmdstan_path() to change the path
    > library(posterior)
    This is posterior version 0.1.2
    > library(bayesplot)
    This is bayesplot version 1.7.2
    - Online documentation and vignettes at mc-stan.org/bayesplot
    - bayesplot theme set to bayesplot::theme_default()
       * Does _not_ affect other ggplot2 plots
       * See ?bayesplot_theme_set for details on theme setting

    Attachement du package : ‘bayesplot’

    The following object is masked from ‘package:posterior’:

        rhat

    > color_scheme_set("brightblue")
    > install_cmdstan(cores = 2,overwrite=T)
    * Latest CmdStan release is v2.24.0
    * Installing CmdStan v2.24.0 in C:\Users\Antoine\Documents/.cmdstanr/cmdstan-2.24.0
    * Downloading cmdstan-2.24.0.tar.gz from GitHub...
    * Removing the existing installation of CmdStan...
    * Download complete
    * Unpacking archive...
    * Building CmdStan binaries...
    Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
    cp bin/windows-stanc bin/stanc.exe
    g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.7 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.2.0/include  -D_USE_MATH_DEFINES  -DBOOST_DISABLE_ASSERTS      -c -fvisibility=hidden -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
    cd stan/lib/stan_math/lib/boost_1.72.0; ./bootstrap.bat gcc
    Building Boost.Build engine
    g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.7 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.2.0/include  -D_USE_MATH_DEFINES  -DBOOST_DISABLE_ASSERTS      -c -fvisibility=hidden -o bin/cmdstan/print.o src/cmdstan/print.cpp
    C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program: No such file or directory
    C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
    collect2.exe: error: ld returned 1 exit status
    Fichier introuvable

    Failed to build Boost.Build engine.
    Please consult bootstrap.log for further diagnostics.

    mingw32-make.exe: *** [make/command:35: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1
    mingw32-make.exe: *** Waiting for unfinished jobs....

    Warning message:
    There was a problem during installation. See the error message(s) above. 

You can ignore that one. Still getting to the bottom as to why it occasionally occurs on some Windows installs. I think you may have another compiler in PATH and that does not play well.

Anyhow, just try.

library(cmdstanr)

file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
mod <- cmdstan_model(file)
data_list <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))

fit <- mod$sample(
  data = data_list,
  seed = 123,
  chains = 4,
  parallel_chains = 2,
  refresh = 500
)

The first compile will take some time, but then everything will work as it should.

2 Likes