Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with install_cmdstan() under Windows 10, R 4.4.0, RTools 4.4 #962

Open
jonathan-g opened this issue May 6, 2024 · 11 comments
Open
Labels
bug Something isn't working

Comments

@jonathan-g
Copy link

Describe the bug
I get a fatal error when running install_cmdstan() under Windows 10, R 4.4.0, RTools 4.4

To Reproduce
Run install_cmdstan()

Expected behavior
Successful installation of cmdstan.

Operating system
Windows 10

CmdStanR version number
0.7.1, freshly installed from GitHub, SHA = 21888fa

Additional context

> install_cmdstan(cores=8)
The C++ toolchain required for CmdStan is setup properly!
trying URL 'https://api.github.com/repos/stan-dev/cmdstan/releases/latest'
Content type 'application/json; charset=utf-8' length 14898 bytes (14 KB)
downloaded 14 KB

* Latest CmdStan release is v2.34.1
* Installing CmdStan v2.34.1 in C:\Users\gilligjm\Documents/.cmdstan/cmdstan-2.34.1
* Downloading cmdstan-2.34.1.tar.gz from GitHub...
trying URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.34.1/cmdstan-2.34.1.tar.gz'
Content type 'application/octet-stream' length 51577679 bytes (49.2 MB)
downloaded 49.2 MB

* Download complete
* Unpacking archive...
* Building CmdStan binaries...
INFO: Could not find files for the given pattern(s).
cp bin/windows-stanc bin/stanc.exe
      0 [main] mkdir (19248) C:\rtools44\usr\bin\mkdir.exe: *** fatal error - add_item ("\??\C:\rtools44", "/", ...) failed, errno 1

Followed by a stack trace.

Session Info

R version 4.4.0 (2024-04-24 ucrt) 
Platform: x86_64-w64-mingw32/x64 
Running under: Windows 10 x64 (build 19045)  

Matrix products: default   

locale: [1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 [4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8      

time zone: America/Chicago 
tzcode source: internal  

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

other attached packages: 
[1] cmdstanr_0.7.1  

loaded via a namespace (and not attached):  
[1] vctrs_0.6.5          knitr_1.46           cli_3.6.2            xfun_0.43            rlang_1.1.3          processx_3.8.4        
[7] generics_0.1.3       tensorA_0.36.2.1     jsonlite_1.8.8       gitcreds_0.1.2       glue_1.7.0           backports_1.4.1      
[13] pkgbuild_1.4.4       distributional_0.4.0 ps_1.7.6             fansi_1.0.6          tibble_3.2.1         abind_1.4-5          
[19] lifecycle_1.0.4      compiler_4.4.0       posterior_1.5.0      pkgconfig_2.0.3      rstudioapi_0.16.0    R6_2.5.1             
[25] utf8_1.2.4           pillar_1.9.0         curl_5.2.1           callr_3.7.6          magrittr_2.0.3       checkmate_2.3.1      
[31] withr_3.0.0          tools_4.4.0          remotes_2.5.0        desc_1.4.3
--
@jonathan-g jonathan-g added the bug Something isn't working label May 6, 2024
@andrjohns
Copy link
Collaborator

That's a very odd one. What output do you get from:

Sys.getenv("PATH")
Sys.getenv("R_RTOOLS44_PATH")

@andrjohns
Copy link
Collaborator

Also, is this a local computer & installation or a remote cluster/server?

@jonathan-g
Copy link
Author

> Sys.getenv("PATH") 
[1] "C:\\Python38\\Scripts;C:\\Python38;C:\\rtools44\\x86_64-w64-mingw32.static.posix\\bin;C:\\rtools44\\usr\\bin;C:\\rtools44\\mingw64\\bin;C:\\rtools44\\ucrt64\\bin;C:\\Program Files\\R\\R-4.4.0\\bin\\x64;C:\\Python38\\Scripts;C:\\Python38;C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program Files\\PuTTY;C:\\Program Files\\Calibre2;D:\\program_files\\local\\SysinternalsSuite;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files\\nodejs;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files (x86)\\GnuPG\\bin;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Bitvise SSH Client;C:\\Program Files\\dotnet;C:\\Program Files\\Pandoc;C:\\Program Files\\TortoiseGit\\bin;C:\\Program Files\\Git\\cmd;C:\\Users\\Public\\ProgramFiles\\hugo;D:\\Anaconda\\condabin;C:\\Users\\gilligjm\\AppData\\Local\\Programs\\Java\\jdk-21.0.2\\bin;C:\\Users\\gilligjm\\AppData\\Roaming\\npm;D:\\program_files\\local\\qpdf\\bin;C:\\Users\\gilligjm\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\gilligjm\\AppData\\Local\\atom\\bin;C:\\Users\\gilligjm\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64;C:\\Users\\gilligjm\\AppData\\Local\\Box\\Box Edit;C:\\Program Files\\RStudio\\resources\\app\\bin\\quarto\\bin;C:\\Program Files\\RStudio\\resources\\app\\bin\\postback" 

> Sys.getenv("R_RTOOLS44_PATH") 
[1] "C:\\rtools44/x86_64-w64-mingw32.static.posix/bin;C:\\rtools44/usr/bin"
--

@jonathan-g
Copy link
Author

This is a local computer and installation. It's the desktop computer in my office.

@andrjohns
Copy link
Collaborator

Is there any antivirus software installed aside from the standard Windows defender?

@jonathan-g
Copy link
Author

Only Windows Defender

@andrjohns
Copy link
Collaborator

Hmm very strange, are you able to install R packages from source? Like:

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

@cdriveraus
Copy link

I'm getting the same error and can install other packages from source just fine.

@andrjohns
Copy link
Collaborator

I'm getting the same error and can install other packages from source just fine.

Concerning! Given that the error is concerning mkdir.exe, can you try the following and see if they also error:

dir.create(file.path(tempdir(), "test1"))
dir.exists(file.path(tempdir(), "test1"))

system2("C:/rtools44/usr/bin/mkdir.exe", file.path(tempdir(),"test2"))
dir.exists(file.path(tempdir(), "test2"))

@cdriveraus
Copy link

cdriveraus commented May 14, 2024

Ok, I figured it out (in my case at least). There was a 'problem with the toolchain' even though I had installed rtools 4.4. This problem was nicely detected and fixed by cmdstanr, but only after I tried to update cmdstan.

@hansvancalster
Copy link

I also had trouble getting everything in working order after upgrade from R 4.3.x to R 4.4.0 on Windows 10. The following steps worked for me:

install.packages("cmdstanr", repos = c("https://stan-dev.r-universe.dev/", "https://cloud.r-project.org/"))
cmdstanr::check_cmdstan_toolchain()
# if error, try:
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
#install cmdstan
cmdstanr::install_cmdstan(cores = 2)
#test installation:
library(cmdstanr)
file <- file.path(cmdstan_path(), "examples/bernoulli/bernoulli.stan")
mod <- cmdstan_model(file)
stan_data <- list(N = 10, y = c(0,1,0,0,0,0,0,0,0,1))
fit_mcmc <- mod$sample(
  data = stan_data,
  seed = 123,
  chains = 2,
  parallel_chains = 2
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants