Rstan in vscode?

Good day, I am totally new to the world of Stan, rstan, and brms. I am now capable of running a basic brms model in Rstudio using the example provided here ( However, I find Rstudio to be slow and I found out that vscode is a nice IDE for R. The problem I have is that I can’t find a way to make my model run in vs code, even though I can do it in Rstudio without problem. Do you know if its because I have to specify file paths in vscode, or is it only because stan does not work with vscode? Here is the code and the error message in vscode (classic error message seen when there are compilation problems with Rtools, etc…) :

library(brms) # for the analysis
library(haven) # to load the SPSS .sav file
library(tidyverse) # needed for data manipulation.

r$> popular2data <- read_sav(file = “

r$> popular2data <- select(popular2data, pupil, class, extrav, sex, texp, pop

r$> interceptonlymodeltest <- brm(popular ~ 1 + (1 | class),
data = popular2data,
warmup = 100,
iter = 200,
chains = 2,
inits = “random”,
cores = 2)
Compiling the C++ model
Error in system(cmd, intern = !verbose) : ‘C:/Program’ not found
Error in sink(type = “output”) : invalid connection

Here is my session info :

R version 4.0.0 (2020-04-24)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

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

other attached packages:
[1] ggridges_0.5.2 ggthemes_4.2.0 ggmcmc_1.4.1
[4] RColorBrewer_1.1-2 forcats_0.5.0 stringr_1.4.0
[7] dplyr_0.8.5 purrr_0.3.4 readr_1.3.1
[10] tidyr_1.0.2 tibble_3.0.1 tidyverse_1.3.0
[13] haven_2.2.0 brms_2.12.0 Rcpp_1.0.4.6
[16] rstan_2.19.3 ggplot2_3.3.0 StanHeaders_2.19.2

loaded via a namespace (and not attached):
[1] nlme_3.1-147 fs_1.4.1 matrixStats_0.56.0
[4] xts_0.12-0 lubridate_1.7.8 threejs_0.3.3
[7] httr_1.4.1 tools_4.0.0 backports_1.1.6
[10] R6_2.4.1 DT_0.13 DBI_1.1.0
[13] colorspace_1.4-1 withr_2.2.0 GGally_1.5.0
[16] tidyselect_1.0.0 gridExtra_2.3 prettyunits_1.1.1
[19] processx_3.4.2 Brobdingnag_1.2-6 curl_4.3
[22] compiler_4.0.0 rvest_0.3.5 cli_2.0.2
[25] xml2_1.3.2 shinyjs_1.1 colourpicker_1.0
[28] scales_1.1.0 dygraphs_1.1.1.6 mvtnorm_1.1-0
[31] callr_3.4.3 digest_0.6.25 base64enc_0.1-3
[34] pkgconfig_2.0.3 htmltools_0.4.0 dbplyr_1.4.3
[37] fastmap_1.0.1 htmlwidgets_1.5.1 rlang_0.4.5
[40] readxl_1.3.1 rstudioapi_0.11 shiny_1.4.0.2
[43] generics_0.0.2 zoo_1.8-7 jsonlite_1.6.1
[46] crosstalk_1.1.0.1 gtools_3.8.2 inline_0.3.15
[49] magrittr_1.5 loo_2.2.0 bayesplot_1.7.1
[52] Matrix_1.2-18 munsell_0.5.0 fansi_0.4.1
[55] abind_1.4-5 lifecycle_0.2.0 stringi_1.4.6
[58] pkgbuild_1.0.7 plyr_1.8.6 grid_4.0.0
[61] parallel_4.0.0 promises_1.1.0 crayon_1.3.4
[64] miniUI_0.1.1.1 lattice_0.20-41 hms_0.5.3
[67] ps_1.3.2 pillar_1.4.4 igraph_1.2.5
[70] markdown_1.1 shinystan_2.5.0 reshape2_1.4.4
[73] stats4_4.0.0 rstantools_2.0.0 reprex_0.3.0
[76] glue_1.4.0 modelr_0.1.7 vctrs_0.2.4
[79] httpuv_1.5.2 cellranger_1.1.0 gtable_0.3.0
[82] reshape_0.8.8 assertthat_0.2.1 mime_0.9
[85] xtable_1.8-4 broom_0.5.6 coda_0.19-3
[88] later_1.0.0 rsconnect_0.8.16 shinythemes_1.1.2
[91] ellipsis_0.3.0 bridgesampling_1.0-0

Here is the output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))) :
( I suspect the problem comes from here)
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:\Users\maxim\OneDrive\Documents/.R/Makevars’: No such file or directory

Thank you very much for your help and sorry if this is a basic issue with a simple solution.

vscode seems to not be quoting paths correctly. I presume that should be like C:/Program Files/R/.... It might work if you install everything in directories without internal spaces like Program Files.

Thank you very much for your fast reply.

Do you think I could just move the folder and then modify my PATH variables, or I should uninstall and reinstall everything in a new folder without spaces?

I would uninstall and reinstall.

Thank you very much I did it and everything works fine!