rstudio / rstudio/packrat

Problem restoring in offline environment

Open
#454 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
409
Forks
89
PR merge metrics
No merged PRs in 30d

Description

Brief description

In short, when installing packages, packrat does not allow to have some configure.vars or configure.args in global options sets in .Rprofile.site or .Rprofile as it launch installation with R --vanilla CMD INSTALL. That is problematic in some case where these options are used to control specific compilation for packages.

why ?

I am using packrat to prepare content for deployment in an offline environment.
For that we have an internal CRAN mirror that is used by packrat to download sources.
One of the package is {stringi}. The CRAN version of the package needs internet to download ICU.
To deal with this, I follow the INSTALL doc of stringi that explains we could use configure.vars after downloading icu.

To do that globally, we download icu, put it in a shared folder then set in .Rprofile.site on the server

# Some default configure.vars for install.packages (see help("install.packages"))
options(
  configure.vars = list(
    # ICU > 52 required. At RTE, we have 50 only. 
    # `icudt55l.zip` to download at https://github.com/gagolews/stringi/raw/master/src/icu55/data/icudt55l.zip
    # and put locally if on offline environnement
    stringi = c("ICUDT_DIR=/mnt/R/site-library/ICU55/data/")
  )
)

This allows to do install.packages("stringi") with a CRAN version and this configure.vars option pick form the options as stated in the install.packages help page.

However, packrat does not work that way, the option is not pick and packrat::restore freeze because stringi can't be installed.

I wanted to report this in case it was not know.

What are my solutions ?
  • have access to internet. *Not possible here
  • see with stringi developper to prevent a freeze in installation and throw an error if icu zip data cannot be downloaded (it freezes due to that currently). Do not know if possible to do
  • Compile a tar.gz version of stringi with ICU inside as it is possible,and publish on an internal CRAN. Not a generic solution as I also need configure.vars and configure.args on other packages and demand external work if I use this kind of solution for all concerned packages. (keeping up to date internal CRAN)
  • install each required linux deps on the system. not always possible like currently in my case
  • use getOption("devtools.install.args") that it picked by packrat::install as argument to pass to R CMD INSTALL. Currently trying to understand.
    EDIT: it is not possible because we can't control which of the named element of getOption("configure.vars") to pass to R CMD INSTALL. install.packages does this name resolution but not devtools::install nor packrat::install. it seems devtools.install.args is for other R CMD INSTALL arguments. only possibility could be to manually install the package in packrat mode before restoring, but it is not how packrat should work. I do not see a good automated solution on that...
  • pre-install some packages and use packrat cache mechanism for every project on the server. Need a POC to see if possible

If you have any experience with all this, please share.

I really wonder if this kind of behaviour for install.packages should be included in other installation packages like devtools, packrat or remotes.

If you think it is a case to include inside packrat, I could try work on it.

At the end, a good use case to document somewhere.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing packrat::restore and packrat::install, then compare their R CMD INSTALL invocation with install.packages handling of getOption("configure.vars"). A complete fix should let offline restores select the package-specific configure.vars or configure.args needed by packages such as stringi, without requiring manual pre-installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.