Possible misadaptation of `brms` and `cmdstanr 2.30`

This :

> foo <- brm(bf(mvbind(DeltaPoids, DeltaPouls, DeltaTAS, DeltaTAD)~DeltaDate,
                family=gaussian)+set_rescor(TRUE),
             data=nData, sample_prior="yes", save_pars=save_pars("all"),
              backend="rstan", future=TRUE, cores=4)

runs, but this :

> bar <- brm(bf(mvbind(DeltaPoids, DeltaPouls, DeltaTAS, DeltaTAD)~DeltaDate,
                       family=gaussian)+set_rescor(TRUE),
             data=nData, sample_prior="yes", save_pars=save_pars("all"),
             backend="cmdstanr", future=TRUE, cores=4)

fails wit the following message :

bin/stanc: unknown option '--canonicalize=deprecations,braces,parentheses'.
Usage: stanc [option] ... <model_file.stan>
  --debug-lex                     For debugging purposes: print the lexer actions
  --debug-parse                   For debugging purposes: print the parser actions
  --debug-ast                     For debugging purposes: print the undecorated AST, before semantic checking
  --debug-decorated-ast           For debugging purposes: print the decorated AST, after semantic checking
  --debug-generate-data           For debugging purposes: generate a mock dataset to run the model on
  --debug-mir                     For debugging purposes: print the MIR as an S-expression.
  --debug-mir-pretty              For debugging purposes: pretty-print the MIR.
  --debug-optimized-mir           For debugging purposes: print the MIR after it's been optimized. Only has an effect when optimizations are turned on.
  --debug-optimized-mir-pretty    For debugging purposes: pretty print the MIR after it's been optimized. Only has an effect when optimizations are turned on.
  --debug-transformed-mir         For debugging purposes: print the MIR after the backend has transformed it.
  --debug-transformed-mir-pretty  For debugging purposes: pretty print the MIR after the backend has transformed it.
  --dump-stan-math-signatures     Dump out the list of supported type signatures for Stan Math backend.
  --warn-uninitialized            Emit warnings about uninitialized variables to stderr. Currently an experimental feature.
  --warn-pedantic                 Emit warnings about common mistakes in Stan programs.
  --auto-format                   Pretty prints the program to the console
  --print-canonical               Prints the canonicalized program to the console
  --version                       Display stanc version number
  --name                          Take a string to set the model name (default = "$model_filename_model")
  --O                             Allow the 
compiler to apply all optimizations to the Stan code.
  --o                             Take the path to an output file for generated C++ code (default = "$name.hpp")
  --print-cpp                     If set, output the generated C++ Stan model class to stdout.
  --allow-undefined               Do not fail if a function is declared but not defined
  --allow_undefined               Deprecated. Same as --allow-undefined.
  --include-paths                 Takes a comma-separated list of directories that may contain a file in an #include directive (default = "")
  --include_paths                 Deprecated. Same as --include-paths.
  --use-opencl                    If set, try to use matrix_cl signatures.
  --standalone-functions          If set, the generated C++ will be the standalone functions C++ code.
  --filename-in-msg               Sets the filename used in compiler errors. Uses actual filename by default.
  --info                          If set, print information about the model.
  -help                           Display this list of options
  --help                          Display this list of options

Error in `processx::run(command = stanc_cmd, args = c(stan_file, stanc_flags), …`:
! System command 'stanc' failed
---
Exit status: 2
Stderr (last 10 lines, see `$stderr` for more):
  --allow-undefined               Do not fail if a function is declared but not defined
  --allow_undefined               Deprecated. Same as --allow-undefined.
  --include-paths                 Takes a comma-separated list of directories that may contain a file in an #include directive (default = "")
  --include_paths                 Deprecated. Same as --include-paths.
  --use-opencl                    If set, try to use matrix_cl signatures.
  --standalone-functions          If set, the generated C++ will be the standalone functions C++ code.
  --filename-in-msg               Sets the filename used in compiler errors. Uses actual filename by default.
  --info                          If set, print information about the model.
  -help                           Display this list of options
  --help                          Display this list of options
---
Type .Last.error to see the more details.
> .Last.error
<system_command_status_error/rlib_error_3_0/rlib_error/error>
Error in `processx::run(command = stanc_cmd, args = c(stan_file, stanc_flags), …`:
! System command 'stanc' failed
---
Exit status: 2
Stderr (last 10 lines, see `$stderr` for more):
  --allow-undefined               Do not fail if a function is declared but not defined
  --allow_undefined               Deprecated. Same as --allow-undefined.
  --include-paths                 Takes a comma-separated list of directories that may contain a file in an #include directive (default = "")
  --include_paths                 Deprecated. Same as --include-paths.
  --use-opencl                    If set, try to use matrix_cl signatures.
  --standalone-functions          If set, the generated C++ will be the standalone functions C++ code.
  --filename-in-msg               Sets the filename used in compiler errors. Uses actual filename by default.
  --info                          If set, print information about the model.
  -help                           Display this list of options
  --help                          Display this list of options
---
Backtrace:
1. brms::brm(bf(mvbind(DeltaPoids, DeltaPouls, DeltaTAS, DeltaTAD) ~ DeltaDate, …
2. brms:::.make_stancode(bterms, data = data, prior = prior, stanvars = stanvars, …
3. brms:::.canonicalize_stan_model(tmp_file, overwrite_file = FALSE)
4. processx::run(command = stanc_cmd, args = c(stan_file, stanc_flags), …
5. processx:::throw(new_process_error(res, call = sys.call(), echo = echo, …
> 

which could as well be in Akkadian…

FWIW :

OS : Linux (Debian testing)

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux bookworm/sid

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] rstan_2.21.5         StanHeaders_2.21.0-7 brms_2.17.0         
 [4] Rcpp_1.0.9           cmdstanr_0.5.2       ggplot2_3.3.6       
 [7] mgcv_1.8-40          nlme_3.1-158         digest_0.6.29       
[10] DBI_1.1.3           

loaded via a namespace (and not attached):
  [1] TH.data_1.1-1        minqa_1.2.4          colorspace_2.0-3    
  [4] ellipsis_0.3.2       ggridges_0.5.3       estimability_1.4    
  [7] markdown_1.1         base64enc_0.1-3      listenv_0.8.0       
 [10] farver_2.1.1         DT_0.23              bit64_4.0.5         
 [13] fansi_1.0.3          mvtnorm_1.1-3        bridgesampling_1.1-2
 [16] codetools_0.2-18     splines_4.2.1        cachem_1.0.6        
 [19] knitr_1.39           shinythemes_1.2.0    bayesplot_1.9.0     
 [22] projpred_2.1.2       jsonlite_1.8.0       nloptr_2.0.3        
 [25] shiny_1.7.1          compiler_4.2.1       emmeans_1.7.5       
 [28] backports_1.4.1      assertthat_0.2.1     Matrix_1.4-1        
 [31] fastmap_1.1.0        cli_3.3.0            later_1.3.0         
 [34] htmltools_0.5.2      prettyunits_1.1.1    igraph_1.3.2        
 [37] coda_0.19-4          gtable_0.3.0         glue_1.6.2          
 [40] reshape2_1.4.4       dplyr_1.0.9          posterior_1.2.2     
 [43] vctrs_0.4.1          crosstalk_1.2.0      tensorA_0.36.2      
 [46] xfun_0.31            stringr_1.4.0        globals_0.15.1      
 [49] ps_1.7.1             lme4_1.1-30          mime_0.12           
 [52] miniUI_0.1.1.1       lifecycle_1.0.1      gtools_3.9.3        
 [55] future_1.26.1        MASS_7.3-57          zoo_1.8-10          
 [58] scales_1.2.0         colourpicker_1.1.1   promises_1.2.0.1    
 [61] Brobdingnag_1.2-7    parallel_4.2.1       sandwich_3.0-2      
 [64] inline_0.3.19        shinystan_2.6.0      gamm4_0.2-6         
 [67] memoise_2.0.1        gridExtra_2.3        loo_2.5.1           
 [70] stringi_1.7.8        RSQLite_2.2.14       dygraphs_1.1.1.6    
 [73] checkmate_2.1.0      boot_1.3-28          pkgbuild_1.3.1      
 [76] rlang_1.0.4          pkgconfig_2.0.3      matrixStats_0.62.0  
 [79] distributional_0.3.0 lattice_0.20-45      purrr_0.3.4         
 [82] rstantools_2.2.0     htmlwidgets_1.5.4    labeling_0.4.2      
 [85] bit_4.0.4            processx_3.7.0       tidyselect_1.1.2    
 [88] parallelly_1.32.0    plyr_1.8.7           magrittr_2.0.3      
 [91] R6_2.5.1             generics_0.1.3       multcomp_1.4-19     
 [94] pillar_1.7.0         withr_2.5.0          xts_0.12.1          
 [97] survival_3.3-1       abind_1.4-5          tibble_3.1.7        
[100] crayon_1.5.1         utf8_1.2.2           grid_4.2.1          
[103] blob_1.2.3           callr_3.7.0          threejs_0.3.3       
[106] xtable_1.8-4         httpuv_1.6.5         RcppParallel_5.1.5  
[109] stats4_4.2.1         munsell_0.5.0        shinyjs_2.1.0       
> system("/usr/local/cmdstan/bin/stanc --version")
stanc3 766bbf10 (Unix)
> 

This might be a subtle misfeature introduced by my cmdstan version (hand-compiled from the github tree).

I just checked that cmdstanr is at 0.5.2, i. e. the latest available…

Advice ?

That error indicates that you’re using a version of stanc3 (included by cmdstan) thats very out of date. I suspect that your hand-built cmdstan might be based on an old source or similar.

The simplest fix is to download the latest version of the stanc3 binary for your OS from: Release v2.30.0 (1 July 2022) · stan-dev/stanc3 · GitHub

And replace your local cmdstan/bin/stancfile

1 Like

Thanks. Totally replacing the cmdstan tree did the trick.

I may have goofed in updating my (former) git tree ; what I did was essentially :

git fetch
git pull
make -j8 build

Did I err ?