stan-dev / rstanarm

rstanarm R package for Bayesian applied regression modeling
https://mc-stan.org/rstanarm
GNU General Public License v3.0
388 stars 133 forks source link

Unable to install the development branch of 'rstanarm' on Win10 #442

Open mbostanara opened 4 years ago

mbostanara commented 4 years ago

Summary:

I need to get access to the stan_surv() function from 'rstanarm' development package; however, I am unable to install it on my machine.

Description:

I tried to install 'rstanarm' to use it for Bayesian survival analysis in two ways:

  1. devtools::install_github("stan-dev/rstanarm", build_vignettes = FALSE) -> It installed after uninstalling and re-installing many other packages like 'glue', 'ps', etc. But did not have 'stan_surv' function in the end. There was a warning too:

    Warning message:
    In utils::untar(tarfile, ...) :
    ‘tar.exe -xf "C:\Users\z3529455\AppData\Local\Temp\RtmpstuJZu\file755416331bd.tar.gz" -C "C:/Users/z3529455/AppData/Local/Temp/RtmpstuJZu/remotes75543a041272"’ returned error code 1
  2. devtools::install_github("stan-dev/rstanarm",ref = "feature/survival", build_vignettes = FALSE) -> did not install with this error: installation of package ‘rstanarm’ had non-zero exit status. Here is the error:

    
    Error: Failed to install 'rstanarm' from GitHub:
    (converted from warning) installation of package ‘C:/Users/z3529455/AppData/Local/Temp/RtmpstuJZu/file75541be324a9/rstanarm_2.19.1.tar.gz’ had non-zero exit status
    In addition: Warning message:
    In utils::untar(tarfile, ...) :
    ‘tar.exe -xf "C:\Users\z3529455\AppData\Local\Temp\RtmpstuJZu\file7554777d77a3.tar.gz" -C "C:/Users/z3529455/AppData/Local/Temp/RtmpstuJZu/remotes7554f9c35f"’ returned error code 1

Would someone please help me with that? I am in an urgent need!

#### R Version:
The version of R you are running (e.g., from `getRversion()`)
3.6.3

#### Operating System:
My operating system is Windows10
ermeel86 commented 4 years ago

Have you tried remotes::install_github? And try to ignore, at first, any packages that need updates.

mbostanara commented 4 years ago

Thank you @ermeel86 for your reply. I don't think I have tried it. Would you please explain it more? I am not sure how can I do that.

jgabry commented 4 years ago

We're trying to figure this out ourselves too (e.g. https://github.com/stan-dev/r-packages/issues/2#issuecomment-653013949)! There seem to be several different issues on Windows.

By any chance does adding build_opts = c("--no-multiarch") work? For example,

remotes::install_github(
  "stan-dev/rstanarm", 
  ref = "feature/survival", 
  build_vignettes = FALSE,
  build_opts = c("--no-multiarch"), 
  upgrade = "never" # this should ignore packages that need updates like @ermeel86 suggested (not sure if necessary though) 
)
mbostanara commented 4 years ago

Thank you @jgabry for your reply. I tried to install 'rstanarm' via the code you provided. Here is the error I received in the end:

cc1plus.exe: out of memory allocating 5401568 bytes
make: *** [C:/Users/z3529455/DOCUME~1/R/R-40~1.1/etc/i386/Makeconf:227: stan_files/jm.o] Error 1
rm stan_files/jm.cc stan_files/binomial.cc stan_files/lm.cc stan_files/continuous.cc stan_files/bernoulli.cc stan_files/polr.cc stan_files/surv.cc stan_files/count.cc stan_files/mvmer.cc
ERROR: compilation failed for package 'rstanarm'
* removing 'C:/Users/z3529455/Documents/R/R-4.0.1/library/rstanarm'
* restoring previous 'C:/Users/z3529455/Documents/R/R-4.0.1/library/rstanarm'
Error: Failed to install 'rstanarm' from GitHub:
  (converted from warning) installation of package ‘C:/Users/z3529455/AppData/Local/Temp/RtmpADPI6v/file45b4570138a0/rstanarm_2.19.1.tar.gz’ had non-zero exit status
In addition: Warning message:
In utils::untar(tarfile, ...) :
  ‘tar.exe -xf "C:\Users\z3529455\AppData\Local\Temp\RtmpADPI6v\file45b472906806.tar.gz" -C "C:/Users/z3529455/AppData/Local/Temp/RtmpADPI6v/remotes45b41767b73"’ returned error code 1
GuyHedelin commented 4 years ago

Hi everybody, I have the same kind of error. I tried what was proposed but everything failed. I use Rstudio but it's the same issue with the R console. Even if I run it as administrator I get the following error:

library(devtools) Le chargement a nécessité le package : usethis devtools::install_github("stan-dev/rstanarm", build_vignettes = FALSE) Downloading GitHub repo stan-dev/rstanarm@HEAD stan-dev-rstanarm-5a0ae87/tests/testthat/include: Can't create '\\?\C:\Users\GUY~1.HED\AppData\Local\Temp\Rtmpcx79V0\remotese08331a360d\stan-dev-rstanarm-5a0ae87\tests\testthat\include' stan-dev-rstanarm-5a0ae87/tests/testthat/stan_files: Can't create '\\?\C:\Users\GUY~1.HED\AppData\Local\Temp\Rtmpcx79V0\remotese08331a360d\stan-dev-rstanarm-5a0ae87\tests\testthat\stan_files' tar.exe: Error exit delayed from previous errors. These packages have more recent versions available. It is recommended to update all of them. Which would you like to update?

The error occurs before the update of any package in the list (not shown).

I need the function stan_surv. How can I use it? Is there any possibility to simply have a tarball file to download and directly intall without relying on GitHub?

Thanks in advance for any help

GuyHedelin commented 4 years ago

Hi,

After leaving my comment I tried different things and I could go further but I can't compile the tarball. First I found the taball downloaded from GitHub on my system. Then I gziped it. After removing the locking subdirectory in the library directory I could install the vctrs package manually. The I tried to install the rstanarm_2.21.2.tar.gz file, but I get this error:

install.packages("C:/Users/guy.hedelin/Downloads/rstanarm_2.21.2.tar.gz", repos = NULL, type = "source") installing source* package 'rstanarm' ... using staged installation libs arch - i386 "C:/PROGRA~1/R/R-40~1.2/bin/i386/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" stan_files/continuous.stan Wrote C++ file "stan_files/continuous.cc" "C:/rtools40/mingw32/bin/"g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-40~1.2/include" -DNDEBUG -I"../inst/include" -I"C:/Program Files/R/R-4.0.2/library/StanHeaders/include/src" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -I'C:/Program Files/R/R-4.0.2/library/StanHeaders/include' -I'C:/Program Files/R/R-4.0.2/library/rstan/include' -I'C:/Program Files/R/R-4.0.2/library/BH/include' -I'C:/Program Files/R/R-4.0.2/library/Rcpp/include' -I'C:/Program Files/R/R-4.0.2/library/RcppEigen/include' -I'C:/Program Files/R/R-4.0.2/library/RcppParallel/include' "C:/PROGRA~1/R/R-40~1.2/bin/i386/Rscript" -e "RcppParallel::CxxFlags()" "C:/PROGRA~1/R/R-40~1.2/bin/i386/Rscript" -e "StanHeaders:::CxxFlags()" -flto=jobserver -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c stan_files/continuous.cc -o stan_files/continuous.o g++.exe: error: Files/R/R-4.0.2/library/RcppParallel/include": No such file or directory make: [C:/PROGRA~1/R/R-40~1.2/etc/i386/Makeconf:227: stan_files/continuous.o] Error 1 rm stan_files/continuous.cc ERROR: compilation failed for package 'rstanarm' * removing 'C:/Program Files/R/R-4.0.2/library/rstanarm' Warning in install.packages : installation of package ‘C:/Users/guy.hedelin/Downloads/rstanarm_2.21.2.tar.gz’ had non-zero exit status

  | >

In fact the subdirectory 'C:/Program Files/R/R-4.0.2/library/RcppParallel/include' exists in my library!

Any idea? Perhaps the blank character in the path of windows (but there is no error for the other include two paths in the options)

ermeel86 commented 4 years ago

I am sorry to hear this @GuyHedelin. The situation is really unfortunate. Let’s check with @jgabry and @bgoodri? Any updates on getting this into rstanarm at CRAN? It’s a pity that there is repeated and regular user demand for stan_surv but people can’t use it... Is there anything I can do concretely (testing / coding) to get help getting this finally solved (alternatively leading to a prebuilt binary). Cheers!

GuyHedelin commented 4 years ago

Hi @ermeel86,

I think the error comes from the single quote ' used in the generated script instead of a double quote " that ensures that on windows paths with space in the name are correctly handled. But I don't know how to correct it because I don't have access to the script. I think a build for windows in a zip file could help because there would be no need of any compiling step. If you could do that it would be great. I need the stan_surv for my own work but also in my teaching examples that my students use. As you stated in your paper it is important to promote the bayesian approach to survival.

Cheers!

bgoodri commented 4 years ago

This is probably fixed by the newest StanHeaders on CRAN, but installing rstanarm on Windows is still pretty dicey.

On Sun, Aug 30, 2020 at 11:42 AM GuyHedelin notifications@github.com wrote:

Hi @ermeel86 https://github.com/ermeel86,

I think the error comes from the single quote ' used in the generated script instead of a double quote " that ensures that on windows paths with space in the name are correctly handled. But I don't know how to correct it because I don't have access to the script. I think a build for windows in a zip file could help because there would be no need of any compiling step. If you could do that it would be great. I need the stan_surv for my own work but also in my teaching examples that my students use. As you stated in your paper it is important to promote the bayesian approach to survival.

Cheers!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/442#issuecomment-683435632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZ2XKSWAXZQBWA7NTWLK5TSDJXNHANCNFSM4ODNYUUQ .

GuyHedelin commented 4 years ago

Unfortunataly not, I used the latest StanHeaders on CRAN (2.21.0-6) and the latest RccpEigen and RccpParallel.

sambrilleman commented 4 years ago

Yeah, I can confirm that the whitespace in the Rcpp file path still causes issues even with the new StanHeaders. I moved my R packages to a new location without the space in the file path (C:/Rpackages) and it seemed to fix that error. But it's not really ideal for me (i.e. I would prefer to be able to just keep my R packages in the native location). Fyi, @GuyHedelin I just added the following line to the .Rprofile file in my Documents folder:

.libPaths(c(file.path("C:/Rpackages"), file.path(Sys.getenv("R_HOME"), "library")))

After fixing that issue I was able build the master and feature/survival branches using remotes::install_github(), although I can't work out how to get it to build the roxygen2 documentation. If anyone knows (e.g. is it a build option?), that would be useful.

Also, fwiw, @jgabry @bgoodri, even though I've been able to install using install_github() I've still not been able to build ("Install and Restart" in RStudio) from within the rstanarm.Rproj R project. The build takes forever (I haven't timed it but I think it would have still been building after an hour or so) so I ended up just having to kill it. This was true for both the master and feature/survival branches. I'm not sure what remotes::install_github() is doing differently from the RStudio's "Install and Restart", but it must be something.

bgoodri commented 4 years ago

You can temporarily install this binary version https://win-builder.r-project.org/7Cl7ryfVps8c/rstanarm_2.21.2.zip

GuyHedelin commented 4 years ago

Thank you @bgoodri. I'll give it a try. In fact I succeeded this morning to install it by modifying the function LdFlags in StanHeaders and rewriting some part of Makevars.win to force the use of the short form of the paths (avoiding spaces in pathnames). Nevertheless your binary version can help a lot of people. Thanks to all.

ermeel86 commented 4 years ago

This pre-built binary works for me. Unfortunately it doesn’t come with a manual : documentation for stan_surv, which is rather essential, given the complexity of the underlying model. Any chance we can add this as a default to the binary?

Eren On 31. Aug 2020, 07:11 +0200, bgoodri notifications@github.com, wrote:

You can temporarily install this binary version https://win-builder.r-project.org/7Cl7ryfVps8c/rstanarm_2.21.2.zip — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

jgabry commented 4 years ago

This pre-built binary works for me. Unfortunately it doesn’t come with a manual : documentation for stan_surv, which is rather essential, given the complexity of the underlying model.

Yeah that's a problem! I wonder if this is because rstanarm doesn't track the Rd files on GitHub. I don't remember why that's the case but we should probably change that. rstanarm is pretty much the only R package on GitHub not tracking the Rd files. I'll open a separate issue about this.