user8460166
user8460166

Reputation: 173

Installing packages in R by using binary instead of source files: how to change the default

I just updated R and RStudio to the newest versions (R version 3.5.1 (2018-07-02); RStudio Version 1.1.453) on my Macbook Pro last night. And, then I realized that when I try to install packages in RStudio, it installs from source code by compiling it.

I am using general fuction to install packages (i.e., install.packages(XXXX)). Also, I conformed that when I use R instead of RStudio, the R just installs packages by donwloading binary files.

I have to use RStudio but since it is compiling all packages from source codes, this is taking forever! I would really appreciate it if I could hear how can I have RStudio use binary files instead. Thank you for your help.

install.packages("lavaan") 

Installing package into ‘/usr/local/lib/R/3.5/site-library’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/src/contrib/lavaan_0.6-1.tar.gz' Content type 'application/x-gzip' length 684438 bytes (668 KB) ================================================== downloaded 668 KB

  • installing source package ‘lavaan’ ... ** package ‘lavaan’ successfully unpacked and MD5 sums checked ** R ** data * moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading ** help * installing help indices ** building package indices ** testing if installed package can be loaded
  • DONE (lavaan)

The downloaded source packages are in ‘/private/var/folders/7m/_0cxbz8s02bdp4z7jxk3pky80000gn/T/Rtmp2ThASP/downloaded_packages’

Upvotes: 9

Views: 24939

Answers (1)

user8460166
user8460166

Reputation: 173

This question was posted by myself a while ago, but today I randomly found out the potential reason why R was installing packages from sources instead of binary.

I bought a MacBook Pro (2020) m1 apple silicon and tried to install R and RStudio. When I installed R and RStudio using brew, I realized that R tried to install R packages using sources instead of binaries again!

I spent several hours trying to figure this out and then, reinstalled R from cask instead of a Homebrew version! This seemed to solve the problem. Now all packages are installed from binaries.

brew install --cask r

I am not 100% if that was the best solution. However, I thought that this note might help whoever facing the same issue.

Upvotes: 6

Related Questions