Cannot install rethinking package

Hello,

I am having a heck of a time getting the rethinking package to install. Install hangs up on the lazy loading stage and then throws an error. Tried installing via devtools from github as instructed without success. Tried via remotes from github as alternative, same problem. Tried using pak::pak(β€œuser/repo”) instead of devtools without luck. Downloaded rethinking-master.zip and tried to install from local, but still also hangs up on the lazy loading step. I made sure all dependencies were downloaded and ran again with same issue with lazy loading stage failing.

Any advice for next steps?

R version 4.5.3 installed. Rtools 45 installed and path setup. Installed cmdstanr successfully and toolchain is working properly.

> R.version
               _                                
platform       x86_64-w64-mingw32               
arch           x86_64                           
os             mingw32                          
crt            ucrt                             
system         x86_64, mingw32                  
status                                          
major          4                                
minor          5.3                              
year           2026                             
month          03                               
day            11                               
svn rev        89597                            
language       R                                
version.string R version 4.5.3 (2026-03-11 ucrt)
nickname       Reassured Reassurer     
         
> cmdstanr::check_cmdstan_toolchain()
The C++ toolchain required for CmdStan is setup properly!

Output from attempted github install instructions:

>install.packages(c("coda","mvtnorm","devtools","loo","dagitty","shape"))
>devtools::install_github("rmcelreath/rethinking")
Downloading GitHub repo rmcelreath/rethinking@HEAD
Skipping 1 packages not available: cmdstanr
── R CMD build ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
βœ”  checking for file 'C:\Users\bdemuth\AppData\Local\Temp\RtmpWM65gA\remotes722464fe6f97\rmcelreath-rethinking-ac1b3b2/DESCRIPTION'
─  preparing 'rethinking': (555ms)
βœ”  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a 'data/datalist' file should be added
─  building 'rethinking_2.42.tar.gz' (893ms)
   
Installing package into β€˜C:/Users/bdemuth/AppData/Local/R/win-library/4.5’
(as β€˜lib’ is unspecified)
* installing *source* package 'rethinking' ...
** this is package 'rethinking' version '2.42'
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
ERROR: lazy loading failed for package 'rethinking'
* removing 'C:/Users/bdemuth/AppData/Local/R/win-library/4.5/rethinking'
* restoring previous 'C:/Users/bdemuth/AppData/Local/R/win-library/4.5/rethinking'
Warning messages:
1: `install_github()` was deprecated in devtools 2.5.0.
β„Ή Please use pak::pak("user/repo") instead.
This warning is displayed once per session.
Call lifecycle::last_lifecycle_warnings() to see where this warning was generated. 
2: In i.p(...) :
  installation of package β€˜C:/Users/bdemuth/AppData/Local/Temp/RtmpWM65gA/file72247ff37b19/rethinking_2.42.tar.gz’ had non-zero exit status

Given that, I attempted to install via remotes:

install.packages("remotes")
Installing package into β€˜C:/Users/bdemuth/AppData/Local/R/win-library/4.5’
(as β€˜lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.5/remotes_2.5.0.zip'
Content type 'application/zip' length 436537 bytes (426 KB)
downloaded 426 KB

package β€˜remotes’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\bdemuth\AppData\Local\Temp\RtmpWM65gA\downloaded_packages
> remotes::install_github("rmcelreath/rethinking")
Downloading GitHub repo rmcelreath/rethinking@HEAD
Skipping 1 packages not available: cmdstanr
── R CMD build ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
βœ”  checking for file 'C:\Users\bdemuth\AppData\Local\Temp\RtmpWM65gA\remotes722466cd2076\rmcelreath-rethinking-ac1b3b2/DESCRIPTION'
─  preparing 'rethinking': (561ms)
βœ”  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a 'data/datalist' file should be added
─  building 'rethinking_2.42.tar.gz' (919ms)
   
Installing package into β€˜C:/Users/bdemuth/AppData/Local/R/win-library/4.5’
(as β€˜lib’ is unspecified)
* installing *source* package 'rethinking' ...
** this is package 'rethinking' version '2.42'
** using staged installation
** R
** data
** inst
** byte-compile and prepare package for lazy loading
ERROR: lazy loading failed for package 'rethinking'
* removing 'C:/Users/bdemuth/AppData/Local/R/win-library/4.5/rethinking'
* restoring previous 'C:/Users/bdemuth/AppData/Local/R/win-library/4.5/rethinking'
Warning message:
In i.p(...) :
  installation of package β€˜C:/Users/bdemuth/AppData/Local/Temp/RtmpWM65gA/file72242c1315a3/rethinking_2.42.tar.gz’ had non-zero exit status

I tried uninstalling R and Rstudio both and did fresh installs. I also even attempted R 4.4.3 with rtools 44 as well with no luck even getting through the cmdstanr install steps. So, I am now back to a freshly installed R version 4.5.3 installed with Rtools 45 installed and path setup. Installed cmdstanr successfully and toolchain is working properly. no other version of R, rstudio or Rtools are on my device to conflict. Tried deleting %temp% (rtmp files). No 00Lock temp files.

Hi, and welcome,

It’s been a while, so I don’t know how things are now, but Windows used to have some particularities to have everything play nice.

I’m assuming you already looked into the warnings 1: install_github() was deprecated in devtools 2.5.0. β„Ή Please use pak::pak("user/repo") instead., I don’t know if that would have any immediate implications there, and it is also curious that you get Skipping 1 packages not available: cmdstanr when the check says it’s all set.

Have you tried Linux or WSL, there it would be the kind of thing where the package is looking for the $CMDSTAN environmental variable, don’t know if something similar is happening on Windows, and don’t know what would be the equivalent variable.

Or it could be something else entirely, in which case (and in general) it would be much better if someone who knows more about R/Windows can help.

I did also try the pak:pak(β€œuser/repo”) approach and it still hangs up at lazy loading.

I have not dabbled in WSL, but I will consider that as a potential work around in the future if I cannot resolve the issue in windows.