seroanalytics / epikinetics

https://seroanalytics.github.io/epikinetics/
GNU General Public License v3.0
2 stars 1 forks source link

getting error with package installation #13

Closed avallecam closed 3 weeks ago

avallecam commented 4 weeks ago

Thank you for sharing the installation steps in the README. I installed cmdstanr successfully, but got a lengthy error with installing the package. Sharing the outputs here:

> install.packages('cmdstanr', repos = c('https://stan-dev.r-universe.dev', getOption('repos')))
# Downloading packages -------------------------------------------------------
- Downloading cmdstanr from https://stan-dev.r-universe.dev ... OK [1.5 Mb in 0.67s]
Successfully downloaded 1 package in 9.6 seconds.

The following package(s) will be installed:
- cmdstanr [0.8.1]
These packages will be installed into "~/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32".

Do you want to proceed? [Y/n]: y

# Installing packages --------------------------------------------------------
- Installing cmdstanr ...                       OK [installed binary and cached in 3.0s]
Successfully installed 1 package in 4 seconds.
> remotes::install_github("seroanalytics/epikinetics")
Using GitHub PAT from the git credential store.
Downloading GitHub repo seroanalytics/epikinetics@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                                               
2: CRAN packages only                                
3: None                                              
4: data.table (a5e2bca76... -> b4538a0a1...) [GitHub]

Enter one or more numbers, or an empty line to skip updates: 3
── R CMD build ────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file 'C:\Users\AndreeValleCampos\AppData\Local\Temp\Rtmpa4orvR\remotesd5b0159576d5\seroanalytics-epikinetics-24120fb/DESCRIPTION' (485ms)
─  preparing 'epikinetics': (692ms)
✔  checking DESCRIPTION meta-information ...
─  cleaning src
─  running 'cleanup.win'
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
     NB: this package now depends on R (>= 3.5.0)
     WARNING: Added dependency on R >= 3.5.0 because serialized objects in
     serialize/load version 3 cannot be read in older versions of R.
     File(s) containing such objects:
       'epikinetics/tests/testthat/testdata/testdraws.rds'
       'epikinetics/tests/testthat/testdata/testdraws_multiplecovariates.rds'
       'epikinetics/tests/testthat/testdata/testdraws_nocovariates.rds'
─  building 'epikinetics_0.0.0.9000.tar.gz'
   Warning: file 'epikinetics/cleanup' did not have execute permissions: corrected

Installing package into ‘C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32’
(as ‘lib’ is unspecified)
* installing *source* package 'epikinetics' ...
** using staged installation
** libs
using C++ compiler: 'G__~1.EXE (GCC) 13.2.0'
g++ -std=gnu++17  -I"C:/PROGRA~1/R/R-44~1.0/include" -DNDEBUG  -I'C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/cpp11/include'   -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c convert_log_scale_inverse.cpp -o convert_log_scale_inverse.o
convert_log_scale_inverse.cpp: In function 'cpp11::data_frame convert_log_scale_inverse_cpp(cpp11::writable::list, cpp11::strings)':
convert_log_scale_inverse.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<double>::size_type' {aka 'long long unsigned int'} [-Wsign-compare]
   15 |     for (int j = 0; j < col.size(); j++) {
      |                     ~~^~~~~~~~~~~~
g++ -std=gnu++17  -I"C:/PROGRA~1/R/R-44~1.0/include" -DNDEBUG  -I'C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/cpp11/include'   -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c cpp11.cpp -o cpp11.o
g++ -std=gnu++17  -I"C:/PROGRA~1/R/R-44~1.0/include" -DNDEBUG  -I'C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/cpp11/include'   -I"C:/rtools44/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c simulate_trajectories.cpp -o simulate_trajectories.o
g++ -std=gnu++17 -shared -s -static-libgcc -o epikinetics.dll tmp.def convert_log_scale_inverse.o cpp11.o simulate_trajectories.o -LC:/rtools44/x86_64-w64-mingw32.static.posix/lib/x64 -LC:/rtools44/x86_64-w64-mingw32.static.posix/lib -LC:/PROGRA~1/R/R-44~1.0/bin/x64 -lR
installing via 'install.libs.R' to C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/00LOCK-epikinetics/00new/epikinetics
Warning: Can't find CmdStan makefile to detect version number. Path may not point to valid installation.
Installing cmdstan
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 18597 bytes (18 KB)
==================================================
downloaded 18 KB

* Latest CmdStan release is v2.35.0
* Installing CmdStan v2.35.0 in C:\Users\AndreeValleCampos/.cmdstan/cmdstan-2.35.0
* Downloading cmdstan-2.35.0.tar.gz from GitHub...
Warning: An installation already exists at C:\Users\AndreeValleCampos/.cmdstan/cmdstan-2.35.0. Please remove or rename the installation folder or set overwrite=TRUE.
Error: 
! in callr subprocess.
Caused by error in `process_initialize(self, private, command, args, stdin, stdout, …`:
! Native call to `processx_exec` failed
Caused by error in `chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …`:
! Command 'bin/stanc.exe' not found @win/processx.c:982 (processx_exec)
---
Standard error:
Compiling models: C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/00LOCK-epikinetics/00new/epikinetics/bin/stan/antibody_kinetics_main.stan
Warning messages:
1: Can't find CmdStan makefile to detect version number. Path may not point to valid installation. 
2: Can't find CmdStan makefile to detect version number. Path may not point to valid installation. 
3: Can't find CmdStan makefile to detect version number. Path may not point to valid installation. 
4: Can't find CmdStan makefile to detect version number. Path may not point to valid installation.
---
Backtrace:
 1. tools:::.install_packages()
 2. local do_install(pkg)
 3. local do_install_source(pkg_name, instdir, pkg, desc)
 4. local run_shlib(pkg_name, srcs, instdir, rarch, use_LTO)
 5. local shlib_install(instdir, arch)
 6. base::source("install.libs.R", local = local.env)
 7. | base::withVisible(eval(ei, envir))
 8. | base::eval(ei, envir)
 9. | base::eval(ei, envir)
10. callr::r(func = function(bin_stan) { …
11. callr:::get_result(output = out, options)
12. callr:::throw(callr_remote_error(remerr, output), parent = fix_msg(remerr[[3]]))
---
Subprocess backtrace:
 1. instantiate::stan_package_compile(models = instantiate::stan_package_model…
 2. base::lapply(X = models, FUN = stan_compile_model, verbose = verbose, …
 3. local FUN(X[[i]], ...)
 4. cmdstanr("cmdstan_model")(stan_file = model, compile = TRUE, …
 5. CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, …
 6. local initialize(...)
 7. self$compile(...)
 8. cmdstanr:::get_standalone_hpp(temp_stan_file, stancflags_standalone)
 9. withr::with_path(c(toolchain_PATH_env_var(), tbb_path()), wsl_compatible_r…
10. base::force(code)
11. cmdstanr:::wsl_compatible_run(command = stanc_cmd(), args = c(paste0("--o=", …
12. base::do.call(processx::run, run_args)
13. (function (command = NULL, args = character(), error_on_status = TRUE, …
14. process$new(command, args, echo_cmd = echo_cmd, wd = wd, windows_verbatim_…
15. local initialize(...)
16. processx:::process_initialize(self, private, command, args, stdin, stdout, …
17. base::chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …
18. | base::withCallingHandlers(do.call(".Call", list(.NAME, ...)), error = function(e…
19. | base::do.call(".Call", list(.NAME, ...))
20. | base::.handleSimpleError(function (e) …
21. | base::h(simpleError(msg, call))
22. | base::throw_error(err, parent = e)
23. | base::signalCondition(cond)
24. global (function (e) …
* removing 'C:/Users/AndreeValleCampos/Documents/0projects/epicatador/renv/library/windows/R-4.4/x86_64-w64-mingw32/epikinetics'
Warning messages:
1: In untar2(tarfile, files, list, exdir, restore_times) :
  skipping pax global extended headers
2: In untar2(tarfile, files, list, exdir, restore_times) :
  skipping pax global extended headers
3: In i.p(...) :
  installation of package ‘C:/Users/ANDREE~1/AppData/Local/Temp/Rtmpa4orvR/filed5b053b025fc/epikinetics_0.0.0.9000.tar.gz’ had non-zero exit status

in case useful

> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24 ucrt)
 os       Windows 11 x64 (build 22631)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_United Kingdom.utf8
 ctype    English_United Kingdom.utf8
 tz       Europe/London
 date     2024-10-04
 rstudio  2023.06.0+421 Mountain Hydrangea (desktop)
 pandoc   NA
hillalex commented 4 weeks ago

Ok, looks like an issue with the cmdstan installation, which is installed via the cmdstanr::install_cmdstan command when installing the epikinetics package. The logs show it has been installed to the default location of .cmdstan/cmdstan-2.35.0, but cmdstanr can't find it for some reason.

To debug, first try running cmdstanr::cmdstan_path() to see whether the path to the installation is set correctly. Can you also check whether the executable .cmdstan/cmdstan-2.35.0/bin/stanc.exe exists?

avallecam commented 3 weeks ago

Here is the first output:

 cmdstanr::cmdstan_path()
[1] "C:/Users/AndreeValleCampos/.cmdstan/cmdstan-2.35.0"
Warning messages:
1: Can't find CmdStan makefile to detect version number. Path may not point to valid installation. 
2: Can't find CmdStan makefile to detect version number. Path may not point to valid installation. 

Here are the files within bin

AzureAD+AndreeValleCampos@PC-HGT6VL3 MINGW64 ~/.cmdstan/cmdstan-2.35.0/cmdstan-2.35.0/bin
$ ls -la
total 50284
drwxr-xr-x 1 AzureAD+AndreeValleCampos 4096        0 Oct  3 16:10 ./
drwxr-xr-x 1 AzureAD+AndreeValleCampos 4096        0 Oct  3 16:17 ../
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 15718976 Jun  3 15:52 linux-stanc
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 12066680 Jun  3 15:52 mac-stanc
-rwxr-xr-x 1 AzureAD+AndreeValleCampos 4096 23699408 Jun  3 15:52 windows-stanc*

I found the stanc file in the make folder

AzureAD+AndreeValleCampos@PC-HGT6VL3 MINGW64 ~/.cmdstan/cmdstan-2.35.0/cmdstan-2.35.0/make
$ ls -la
total 21
drwxr-xr-x 1 AzureAD+AndreeValleCampos 4096    0 Oct  3 16:17 ./
drwxr-xr-x 1 AzureAD+AndreeValleCampos 4096    0 Oct  3 16:17 ../
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096  632 Jun  3 15:39 command
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 1055 Jun  3 15:39 local.example
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 3298 Jun  3 15:39 program
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 3159 Jun  3 15:39 stanc
-rw-r--r-- 1 AzureAD+AndreeValleCampos 4096 3911 Jun  3 15:39 tests
hillalex commented 3 weeks ago

Ok, can you try deleting and reinstalling cmdstan to see if there's an error while installing:

avallecam commented 3 weeks ago

it worked!

I when out of the renv-protected project I was trying to do the installation and run

install.packages('cmdstanr', repos = c('https://stan-dev.r-universe.dev', getOption('repos')))
cmdstanr::install_cmdstan()
remotes::install_github("seroanalytics/epikinetics")

then I returned to the renv project and did

remotes::install_github("seroanalytics/epikinetics")

which also worked.

Thanks for the guidelines!