CredibilityLab / groundhog

Reproducible R Scripts Via Date Controlled Installing & Loading of CRAN & Git Packages
https://groundhogr.com/
GNU General Public License v3.0
78 stars 4 forks source link

meta.groundhog fails with no clear explanation #107

Closed cryanking closed 9 months ago

cryanking commented 11 months ago

I have a dockerfile intended to create a fixed container for a published analysis. If I use meta.groundhog to force a change in version (to the state when I started the analysis), it fails without explanation. I get the same failure if I start from groundhog 3.1.2 or 3.1.0. I do not get the error when I set the target date as 10-14-2023 (the most recent allowable, targets 3.1.2 so should pull straight from CRAN).

The dockerfile:

FROM ghcr.io/washu-it-ris/rstudio:4.3.0@sha256:5eb5fc499f43661f962386e117d85cae761df795867a75d45d4f1a5e0f0e29f6
## this base image dervies from "Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)"

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update --fix-missing && \
apt-get install -y build-essential \
libcurl4-gnutls-dev libxml2-dev  \
apt-utils pandoc-citeproc lmodern libgit2-dev libgit2-28 \
libssh2-1-dev libssl-dev libgit2-dev pkg-config zlib1g-dev && \
apt-get clean

RUN useradd docker \
    && mkdir /home/docker \
    && chown docker:docker /home/docker \
    && addgroup docker staff

RUN mkdir --parents /root/R/x86_64-pc-linux-gnu-library/4.3

## this dependcy is weird and won't install by itself
## RUN R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); install.packages(c('git2r'), dependencies=TRUE)"

RUN R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); install.packages(c('groundhog'), dependencies=TRUE); "
RUN R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); library(groundhog); set.groundhog.folder('/root/R_groundhog/'); meta.groundhog('2023-10-01')"

ENTRYPOINT /bin/bash

The output:

> [6/7] RUN R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); library(groundhog); set.groundhog.folder('/root/R_groundhog/'); meta.groundhog('2023-10-13')":                                                                                                               
0.359                                                                                                                                        
0.359 R version 4.3.0 (2023-04-21) -- "Already Tomorrow"                                                                                     
0.359 Copyright (C) 2023 The R Foundation for Statistical Computing                                                                          
0.359 Platform: x86_64-pc-linux-gnu (64-bit)
0.359 
0.359 R is free software and comes with ABSOLUTELY NO WARRANTY.
0.359 You are welcome to redistribute it under certain conditions.
0.359 Type 'license()' or 'licence()' for distribution details.
0.359 
0.359   Natural language support but running in an English locale
0.359 
0.359 R is a collaborative project with many contributors.
0.359 Type 'contributors()' for more information and
0.359 'citation()' on how to cite R or R packages in publications.
0.359 
0.359 Type 'demo()' for some demos, 'help()' for on-line help, or
0.359 'help.start()' for an HTML browser interface to help.
0.359 Type 'q()' to quit R.
0.359 
0.440 > options(repos = c(CRAN = 'https://cloud.r-project.org')); library(groundhog); set.groundhog.folder('/root/R_groundhog/'); meta.groundhog('2023-10-13')
0.449 Attached: 'Groundhog' (Version: 3.1.2)
0.449 Tips and troubleshooting: https://groundhogR.com
0.451 
0.451 Groundhog folder set to: '/root/R_groundhog/
0.451 
0.452 Downloading database with information for all CRAN packages ever published
0.460 trying URL 'http://s3.wasabisys.com/groundhog/cran.toc.rds'
0.714 Content type 'application/octet-stream' length 2094964 bytes (2.0 MB)
0.720 ==================================================
5.754 downloaded 2.0 MB
5.754 
5.754 Downloading database with installation times for all source packages on CRAN
5.755 trying URL 'http://s3.wasabisys.com/groundhog/cran.times.rds'
6.009 Content type 'application/octet-stream' length 840188 bytes (820 KB)
6.009 ==================================================
6.682 downloaded 820 KB
6.682 
8.172 Will now install 1 packages from source
8.177 
8.177 groundhog says: Installing 'groundhog_3.1.1', package #1 (from source) out of 1 needed
8.177 > As of 13:27, the best guess is that all 1 packages will install around 13:27
8.181 trying URL 'https://cloud.r-project.org/src/contrib/Archive/groundhog/groundhog_3.1.1.tar.gz'
8.436 Content type 'application/x-gzip' length 79615 bytes (77 KB)
8.436 ==================================================
8.443 downloaded 77 KB
8.443 
8.694 * installing *source* package ‘groundhog’ ...
8.695 ** package ‘groundhog’ successfully unpacked and MD5 sums checked
8.696 ** using staged installation
8.705 ** R
8.724 ** byte-compile and prepare package for lazy loading
10.44 ** help
10.46 *** installing help indices
10.48 ** building package indices
10.66 ** testing if installed package can be loaded from temporary location
12.06 ** testing if installed package can be loaded from final location
13.25 ** testing if installed package keeps a record of temporary installation path
13.28 * DONE (groundhog)
13.28 
13.28 The package 'groundhog_3.1.1' failed to install.
13.28 
13.28 Possible solutions:
13.28    1) First, simply try again, the error may be a fluke.
13.28    2) Inspect console log, you could be missing non-CRAN dependencies
13.28       (e.g., RTools for Windows, XQuartz for Mac, libssl for Ubuntu),
13.28       or have a connection problem, or another compatibility problem.
13.28    3) If the error indicates that a dependency is missing, re-run the
13.28       groundhog.library() call with option `force.install=TRUE`
13.28    4) If the package that failed is a dependency for a package you want,
13.28       you may install another version of that failed dependency directly
13.28       with a groundhog.library() call, just for that failing pkg, for a 
13.28       different date. Then re-run this groundhog.library() call adding the
13.28       `ignore.deps` argument, to allowing the version mismatch for that pkg.
13.28       Use `toc(<pkg>)` to find out version release dates of 'pkg'.
13.28    5) Similar to (4), use toc(<pkg>) to find the date for the next version
13.28       of the failing pkg and use a date after it for this entire
13.28       groundhog.library() call.
13.28    6) Visit http://groundhogr.com/troubleshooting
13.28 
13.28 
13.28                   --   Installation Failed   --  
13.29 
13.73 Execution halted
------
dockerfile.dockerfile:26
urisohn commented 11 months ago

ok, trying to reproduce without Docker (which I am not familiar with, though I understand what it is). Can you try re-running the meta.groundhog() command right after you get the error? When I produce an error that may be what you are getting, the meta() command runs successfully the 2nd time (not proposing this as a solution, but as a way to diagnose)

cryanking commented 11 months ago

I get the same result as you in that base image: after the error message, running meta.groundhog once gives the error message, running a second time announces "Now using $groundhog_version". That worked upgrading from 3.1.0 to 3.1.1 and 3.1.2. I have to play around with times to force a downgrade, but maybe it is just the error message trigger that is faulty.

If you want a reproducible environment, you can omit the line from the dockerfile

RUN R -e "options(repos = c(CRAN = 'https://cloud.r-project.org')); library(groundhog); set.groundhog.folder('/root/R_groundhog/'); meta.groundhog('2023-10-01')"

and build it docker build -f dockerfile2.dockerfile -t bugtestlocal .

to get a standard image and back at the terminal

docker run --rm -it bugtestlocal R
urisohn commented 9 months ago

I have figured out the bug. It had to do with how groundhog handles conflicts between a loaded package, and a package being installed from source. When installing an old enough version of groundhog that was not available as binary the problem would be triggered (as meta.groundhog() would install from source). This is not a scenario that was part of the battery of tests i was running. I have fixed the problem, should be included in an update i hope to submit to CRAN later this week.