Rstan install trouble

Hi,i am a student from china,who want to use to rstan to analyze my data. However, i found there were some troubles when i install the rstan. I have tried uninstalling all R programs multiple times and it did’t work. See below. Any help would be appreciated.

** using staged installation
** libs
rm -f V8.dll RcppExports.o bindings.o
“G:/R-3.6.0/bin/x64/Rscript.exe” “…/tools/winlibs.R” 6.2.414.50-vista
tools40/usr/mingw_64/bin/g++ -std=gnu++11 -I"G:/R-3.6.0/include" -DNDEBUG -I…/windows/libv8-6.2.414.50-vista/include -DV8_ENABLE_CHECKS -I"G:/R-3.6.0/library/Rcpp/include" -O2 -Wall -mtune=generic -c RcppExports.cpp -o RcppExports.o
sh: G:tools40/usr/mingw_64/bin/g++: No such file or directory
make: *** [G:/R-3.6.0/etc/x64/Makeconf:215: RcppExports.o] Error 127
ERROR: compilation failed for package ‘V8’

  • removing ‘G:/R-3.6.0/library/V8’
    Warning in install.packages :
    installation of package ‘V8’ had non-zero exit status

The downloaded source packages are in
‘C:\Users\86134\AppData\Local\Temp\RtmpyAoL8b\downloaded_packages’

Hi nuosi, have you tried the instructions in the Getting Started page: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started?

Hi, thank you for your help. I have tried, but it still didn’t work.

Can you post the output from:

Sys.getenv("PATH")
Sys.getenv("BINPREF")
readLines("~/.R/Makevars.win")
readLines("~/.Rprofile")
readLines("~/.Renviron")
devtools::session_info("rstan")

thank you for your helping.

  1. Sys.getenv(“PATH”)
    [1] “G:\rtools40\usr\bin;G:\R-3.6.0\bin\x64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\86134\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\86134\AppData\Local\Programs\Python\Python39;G:\rtools40\mingw64\bin;G:\rtools40\mingw32\bin;G:\rtools40;C:\Users\86134\AppData\Local\Microsoft\WindowsApps;C:\Python27;C:\Python27\Scripts;G:\rtools40\mingw64\bin;”
  2. Sys.getenv(“BINPREF”)
    [1] “G:\rtools40/usr/mingw_$(WIN)/bin/”
  3. readLines("~/.R/Makevars.win")
    Error in file(con, “r”) : 无法打开链结
    此外: Warning message:
    In file(con, “r”) :
    无法打开文件’C:/Users/86134/Documents/.R/Makevars.win’: No such file or directory
  4. readLines("~/.Rprofile")
    [1] “Sys.setenv(BINPREF = “G:\rtools40/usr/mingw_$(WIN)/bin/”)”
  5. readLines("~/.Renviron")
    [1] “PATH=”{RTOOLS40_HOME}\\usr\\bin;{PATH}""
  6. devtools::session_info(“rstan”)
  • Session info ----------------------------------------------------------
    setting value
    version R version 3.6.0 (2019-04-26)
    os Windows 10 x64
    system x86_64, mingw32
    ui RStudio
    language (EN)
    collate Chinese (Simplified)_China.936
    ctype Chinese (Simplified)_China.936
    tz Asia/Taipei
    date 2020-11-10

  • Packages --------------------------------------------------------------
    ! package * version date lib source
    assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.3)
    backports 1.2.0 2020-11-02 [1] CRAN (R 3.6.3)
    BH 1.72.0-3 2020-01-08 [1] CRAN (R 3.6.2)
    brio 1.1.0 2020-08-31 [1] CRAN (R 3.6.3)
    callr 3.5.1 2020-10-13 [1] CRAN (R 3.6.3)
    checkmate 2.0.0 2020-02-06 [1] CRAN (R 3.6.3)
    cli 2.1.0 2020-10-12 [1] CRAN (R 3.6.3)
    colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.3)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.3)
    desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.3)
    diffobj 0.3.2 2020-10-05 [1] CRAN (R 3.6.3)
    digest 0.6.27 2020-10-24 [1] CRAN (R 3.6.3)
    ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.3)
    evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.3)
    fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.3)
    farver 2.0.3 2020-01-16 [1] CRAN (R 3.6.3)
    ggplot2 3.3.2 2020-06-19 [1] CRAN (R 3.6.3)
    glue 1.4.2 2020-08-27 [1] CRAN (R 3.6.3)
    gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.3)
    gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.3)
    inline 0.3.16 2020-09-06 [1] CRAN (R 3.6.3)
    isoband 0.2.2 2020-06-20 [1] CRAN (R 3.6.3)
    jsonlite 1.7.1 2020-09-07 [1] CRAN (R 3.6.3)
    labeling 0.4.2 2020-10-20 [1] CRAN (R 3.6.3)
    lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.0)
    lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.3)
    loo 2.3.1 2020-07-14 [1] CRAN (R 3.6.3)
    magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.3)
    MASS 7.3-51.4 2019-03-31 [1] CRAN (R 3.6.0)
    Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.0)
    matrixStats 0.57.0 2020-09-25 [1] CRAN (R 3.6.3)
    mgcv 1.8-28 2019-03-21 [1] CRAN (R 3.6.0)
    munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.3)
    nlme 3.1-139 2019-04-09 [1] CRAN (R 3.6.0)
    pillar 1.4.6 2020-07-10 [1] CRAN (R 3.6.3)
    pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 3.6.3)
    pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.3)
    pkgload 1.1.0 2020-05-29 [1] CRAN (R 3.6.3)
    praise 1.0.0 2015-08-11 [1] CRAN (R 3.6.3)
    prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.3)
    processx 3.4.4 2020-09-03 [1] CRAN (R 3.6.3)
    ps 1.4.0 2020-10-07 [1] CRAN (R 3.6.3)
    R6 2.5.0 2020-10-28 [1] CRAN (R 3.6.3)
    RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.0)
    Rcpp 1.0.5 2020-07-06 [1] CRAN (R 3.6.3)
    RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 3.6.3)
    D RcppParallel 5.0.2 2020-06-24 [1] CRAN (R 3.6.3)
    rematch2 2.1.2 2020-05-01 [1] CRAN (R 3.6.3)
    rlang 0.4.8 2020-10-08 [1] CRAN (R 3.6.3)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.3)
    rstan 2.21.2 2020-07-27 [1] CRAN (R 3.6.3)
    rstudioapi 0.11 2020-02-07 [1] CRAN (R 3.6.3)
    scales 1.1.1 2020-05-11 [1] CRAN (R 3.6.3)
    StanHeaders 2.21.0-6 2020-08-16 [1] CRAN (R 3.6.3)
    testthat 3.0.0 2020-10-31 [1] CRAN (R 3.6.3)
    tibble 3.0.4 2020-10-12 [1] CRAN (R 3.6.3)
    utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.3)
    R V8 [?]
    vctrs 0.3.4 2020-08-29 [1] CRAN (R 3.6.3)
    viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.3)
    waldo 0.2.2 2020-10-15 [1] CRAN (R 3.6.3)
    withr 2.3.0 2020-09-22 [1] CRAN (R 3.6.3)

[1] G:/R-3.6.0/library

D – DLL MD5 mismatch, broken installation.
R – Package was removed from disk.

The above contents are my output.

The issue is that you’re using R3.6 with RTools4.

You need to uninstall RTools4, then install RTools3.5 from here: https://cran.r-project.org/bin/windows/Rtools/Rtools35.exe

Next we need to re-configure R to find the right compilers. So restart R and run:

rt_path = gsub("\\","/",pkgbuild::rtools_path(),fixed=T)
rt_bin = paste0(substr(rt_path,1,nchar(rt_path)-4),"/mingw_$(WIN)/bin/")
writeLines(paste0('PATH="',rt_path,';${PATH}"'), con = "~/.Renviron")
writeLines(paste0('Sys.setenv(BINPREF = "',rt_bin,'")'), con = "~/.Rprofile")

Then we can check the installation by restarting R again and running:

install.packages("jsonlite",type="source")
1 Like

Thank you for your help, I have solved my problems.

2 Likes