Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Studio 1.1.456 (Windows): Why do I sometimes have to install binary packages instead of installing from the source?

I am asking this question because I recently solved a problem installing R Shiny (see below). However, the answers I find don't expand in detail about why this problem occurs and I really want to understand to improve my knowledge of R and why these things happen.

So my attempt to install Shiny in RStudio failed and I believe these are the important error messages:

    Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'httpuv' 1.3.3 is being loaded, but >= 1.4.3 is required
ERROR: lazy loading failed for package 'shiny'
* removing 'C:/Program Files/R/R-3.2.2/library/shiny'
* restoring previous 'C:/Program Files/R/R-3.2.2/library/shiny'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\Sam\AppData\Local\Temp\RtmpuI3XHe/downloaded_packages/shiny_1.1.0.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘shiny’ had non-zero exit status

I went through the usual processes first to find a solution.

  • Checked my RStudio was up to date
  • Checked for and installed package updates

Among the further solutions I tried were:

  • Downloading the package directly from the R Studio interface
  • Using devtools to install Shiny from Github
  • Using install.packages("shiny", dependencies=TRUE).

None of these solutions worked and I believe it is to do with the dependency httpuv, but I'm not sure why.

So in the end the code I was able to use is: install.packages('shiny', type = "binary") and this allowed me to begin using Shiny.

While it wasn't too difficult for me to find a work around for this problem, I would really appreciate someone taking some time out of their day to explain why my version of RStudio in Windows (Version 1.1.456) doesn't support the source package of Shiny and why installing the binary package works. I hate fixing an issue but having zero understanding of it.

R version 3.2.2

Thank you.

like image 736
Samuel Harper Avatar asked Aug 06 '18 09:08

Samuel Harper


1 Answers

Binary versus Source Code Options and Issue

You are experiencing the push-pull friction between the old and new code and R environment dependencies. The reality here is you have to choose between stability and progress. It is difficult to have both.

Consider:

  • You are running R version 3.2.2 in binary form, that R version was released on August 15th 2015. Yet, you are trying to install the latest source code version of Shiny.

    • There is a 3-year delta between the package source code version and R version you are using. The package code and R environment source code have evolved.

    • A lot of changes have occurred between then and now in the compile and source code environment.

Think of it this way.

  • The binary package image is a snapshot of the compile and source code environment assumptions at the time of compilation. If you download the current source code image you are using a snapshot of the current code environment (Now) which includes literally thousands of small incremental changes to the assumptions and dependencies in the source code files and compile environment. if you look in the shiny package description you note:

    • Shiny depends on httpuv which depends on Rcpp
    • httpuv is built on top of the libuv and http-parser C libraries.

      • To get httpuv to compile from source you'll need to match the R Environment, the dependent libraries and source dependencies manually. No small feat.
    • Case in point to compile the above packages from source code (github) you'll likely be using Devtools which if you download in binary form was compiled under R version 3.2.5.

The changes, assumptions and inter-dependencies make for a complex backport compile situation. Hence, the advantage of binary package snapshots.

Options:

In this situation, you generally have two options. You can either:

  1. Download a source version that is old that matches your R version and environment.

    • The downside of this approach is you cannot access current package features.
    • The upside is that the package and R environment match historical context.
  2. Upgrade to a current R environment

    • The downside of this approach is you have to roll with the R releases.
    • The upside is that you get to gain access to the latest package features made available in the current source code.

Solution Options:

How to do the above? In the first case, you might use devtools::install_git and pull the source for a particular branch or version of a package and compile it. In the second, you can upgrade your environment, and then pull and upgrade your packages.

If you want to work off a particular R environment version you have to use the binary versions. Why? These will match the R environment version coding environment assumptions.

This is a classic problem highlighting the push-pull between current code and old code. You have to choose between stability and progress. It is difficult to have both.

I hope the above helps explain the situation.

like image 179
Technophobe01 Avatar answered Oct 05 '22 16:10

Technophobe01