Cannot install cmdstanr on a new machine
Hi Stan dev team,
Thank you for the comprehensive package. I use it a lot on my work desktop but I've yet to be able to install it on my personal device. I am hoping to find some solution/guidance here.
Describe the bug Cannot install cmdstanr on R/4.3.1
Operating system Windows11
CmdStanR version number Cannot be installed.
Additional context I've tried uninstalling R, Rtools, and removing the directory with all downloaded packages (.lib path).
I still cannot install cmdstanr on a fresh machine.
Below is the error message (1) Trying to install from github
> remotes::install_github("stan-dev/cmdstanr")
Downloading GitHub repo stan-dev/cmdstanr@HEAD
Running `R CMD build`...
* checking for file 'C:\Users\tzech\AppData\Local\Temp\RtmpmMqXM2\remotes86981ed23537\stan-dev-cmdstanr-74f39dc/DESCRIPTION' ... OK
* preparing 'cmdstanr':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
Omitted 'LazyData' from DESCRIPTION
* building 'cmdstanr_0.6.0.9000.tar.gz'
Installing package into ‘C:/Users/tzech/AppData/Local/R/win-library/4.3’
(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
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'cmdstanr':
.onLoad failed in loadNamespace() for 'cmdstanr', details:
call: if (endsWith(path, "/")) {
error: missing value where TRUE/FALSE needed
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/tzech/AppData/Local/R/win-library/4.3/cmdstanr'
Warning message:
In i.p(...) :
installation of package ‘C:/Users/tzech/AppData/Local/Temp/RtmpmMqXM2/file86987a0d7eee/cmdstanr_0.6.0.9000.tar.gz’ had non-zero exit status
>
(2) Trying to install from stan repository
> # we recommend running this is a fresh R session or restarting your current session
> install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Installing package into ‘C:/Users/tzech/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
installing the source package ‘cmdstanr’
trying URL 'https://mc-stan.org/r-packages/src/contrib/cmdstanr_0.6.0.tar.gz'
Content type 'application/gzip' length 251575 bytes (245 KB)
downloaded 245 KB
* installing *source* package 'cmdstanr' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'cmdstanr':
.onLoad failed in loadNamespace() for 'cmdstanr', details:
call: if (endsWith(path, "/")) {
error: missing value where TRUE/FALSE needed
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/tzech/AppData/Local/R/win-library/4.3/cmdstanr'
The downloaded source packages are in
‘C:\Users\tzech\AppData\Local\Temp\RtmpmMqXM2\downloaded_packages’
Warning message:
In install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", :
installation of package ‘cmdstanr’ had non-zero exit status
My session info is
> sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.utf8 LC_CTYPE=English_Canada.utf8
[3] LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Canada.utf8
time zone: America/Toronto
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] utf8_1.2.3 R6_2.5.1 magrittr_2.0.3 gtable_0.3.3
[5] remotes_2.4.2.1 glue_1.6.2 tibble_3.2.1 pkgconfig_2.0.3
[9] lifecycle_1.0.3 ggplot2_3.4.2 cli_3.6.1 fansi_1.0.4
[13] scales_1.2.1 grid_4.3.1 vctrs_0.6.3 compiler_4.3.1
[17] tools_4.3.1 munsell_0.5.0 pillar_1.9.0 colorspace_2.1-0
[21] rlang_1.1.1
Many thanks in advance -
Sorry you're having trouble. This is interesting because usually if there are installation issues they have to do with installing CmdStanR after installing the cmdstanr package, but here it's the R package installation that's failing. Are you able to install other R packages from GitHub? Can you try remotes::install_github() with something other than cmdstanr, e.g.:
remotes::install_github("tidyverse/ggplot2")
and see if there's a similar error?
Hi @jgabry
Thank you for the reply!
Yes, it works. I can install packages from github, cran, and bioconductor. It seems to be cmdstanr specific.
> remotes::install_github("tidyverse/ggplot2")
Downloading GitHub repo tidyverse/ggplot2@HEAD
Running `R CMD build`...
* checking for file 'C:\Users\tzech\AppData\Local\Temp\RtmpmMqXM2\remotes869858db7a7a\tidyverse-ggplot2-bde88f8/DESCRIPTION' ... OK
* preparing 'ggplot2':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'ggplot2_3.4.2.9000.tar.gz'
Installing package into ‘C:/Users/tzech/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
* installing *source* package 'ggplot2' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** 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 (ggplot2)
>
Does a .cmdstan folder already exist in your home directory? You can try something like list.files(Sys.getenv("HOME"), all.files = TRUE).
Does a
.cmdstanfolder already exist in your home directory? You can try something likelist.files(Sys.getenv("HOME"), all.files = TRUE).
And I meant to say, if you do have a .cmdstan folder there, what's inside it?
No trace of the hidden file
> x <- list.files(Sys.getenv("HOME"), all.files = TRUE)
> length(x)
[1] 25
> grep(".cmdstan", x)
integer(0)
> grep("cmdstan", x)
integer(0)
Hi @jgabry Can you think of any other lower-hanging fruit I should check?
Many thanks!
Sorry for the slow reply! I'm not great with Windows unfortunately. At first I thought this was the same as this issue as https://github.com/stan-dev/cmdstanr/issues/695, but apparently you don't already have a .cmdstan directory, so I'm not sure. @rok-cesnovar Any ideas?
Hi @jgabry ,
Sorry to resurface an old issue. (Hoping to get some help here). I'm wondering if you guys have run into this issue again over the past year..
I have three computers and I've only been able to install cmdstanr on one of them.
I've avoided this by using rstan on the other two machines.
However, I recently updated my R (4.1 to 4.4) and Rstudio on the only machine with cmdstanr, and now I'm running into the same installation problem.
I've tried my best to look for the hidden .cmdstan folder to no avail.
> file.exists("C:/Users/User/Documents/.cmdstan")
[1] FALSE
> file.exists("C:/Users/User/Downloads/.cmdstan")
[1] FALSE
> file.exists("C:/Users/User/AppData/Local/R/win-library/4.4/.cmdstan")
[1] FALSE
> file.exists("C:/Users/User/AppData/Local/R/win-library/4.2/.cmdstan")
[1] FALSE
I get the same error when I try to install cmdstanr
> # we recommend running this is a fresh R session or restarting your current session
> install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
Installing package into ‘C:/Users/User/AppData/Local/R/win-library/4.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository https://mc-stan.org/r-packages/bin/windows/contrib/4.4:
cannot open URL 'https://mc-stan.org/r-packages/bin/windows/contrib/4.4/PACKAGES'
installing the source package ‘cmdstanr’
trying URL 'https://mc-stan.org/r-packages/src/contrib/cmdstanr_0.8.0.tar.gz'
Content type 'application/gzip' length 853201 bytes (833 KB)
downloaded 833 KB
* installing *source* package 'cmdstanr' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for 'cmdstanr':
.onLoad failed in loadNamespace() for 'cmdstanr', details:
call: if (endsWith(path, "/")) {
error: missing value where TRUE/FALSE needed
Error: loading failed
Execution halted
ERROR: loading failed
* removing 'C:/Users/User/AppData/Local/R/win-library/4.4/cmdstanr'
* restoring previous 'C:/Users/User/AppData/Local/R/win-library/4.4/cmdstanr'
Warning in install.packages :
installation of package ‘cmdstanr’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\User\AppData\Local\Temp\Rtmp0Ozlhb\downloaded_packages’
Or when I copy the cmdstanr folder from .libPath/4.2 to .libPath/4.4
> library(cmdstanr)
Error: package or namespace load failed for ‘cmdstanr’:
.onLoad failed in loadNamespace() for 'cmdstanr', details:
call: if (endsWith(path, "/")) {
error: missing value where TRUE/FALSE needed
OKAY. I figured it out in the end.
I removed old cmdstanr folders in R/win-library/all_previous_versions and that seemed to have fixed the issue.