r-lib / pkgdepends

R Package Dependency Resolution
https://r-lib.github.io/pkgdepends/
Other
97 stars 31 forks source link

Lock file issue after installing `pkgdepends` within a Docker container #336

Closed Faizal-Eeman closed 1 year ago

Faizal-Eeman commented 1 year ago

I'm trying to install pkgdepends in a docker container and the installation seems to be fine. However, when I try to use the functions interactively after the image has been built, I get the following lock file does not exist error.

Example:

> library(pkgdepends);
> new_pkg_deps("dplyr");
Error in lock(lockfile) : 
  Directory of lock file does not exist: '//.cache/R/pkgcache/pkg'
In addition: Warning messages:
1: In normalizePath(cdir) :
  path[1]="//.cache/R/pkgcache": No such file or directory
2: In normalizePath(cdir) :
  path[1]="//.cache/R/pkgcache": No such file or directory
3: In normalizePath(dn) :
  path[1]="//.cache/R/pkgcache/pkg": No such file or directory

Is there anything to be configured in the Dockerfile before installing pkgdepends?

Let me know if you need any specific information to help me out with this.

gaborcsardi commented 1 year ago

Can you show a Dockerfile that fails?

Faizal-Eeman commented 1 year ago

Dockerfile is below. The build succeeds but when I run the image interactively and test out the package, I see the error shown above.

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libxml2 \
    libxml2-dev \
    libcurl4-gnutls-dev \
    build-essential \
    r-base \
    r-base-dev \
    gfortran \
    libfontconfig1-dev \
    libharfbuzz-dev \
    libfribidi-dev \
    libfreetype6-dev \
    libpng-dev \
    libtiff5-dev \
    libjpeg-dev \
    r-cran-rgl \
    git \
    libssl-dev \
    r-cran-curl \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

RUN R -q -e 'install.packages("pkgdepends")'

RUN groupadd -g 500001 testuser && \
    useradd -r -u 500001 -g testuser testuser
Faizal-Eeman commented 1 year ago

Oh, I was able to fix this!

This is to do with how I run the image.

docker run -it --rm -u $(id -u):$(id -g) pkgdepends:dev bash

starts the container without a user name and the lock file location wasn't accessible.

So what worked now is that once I'm in the container, I exported a temp path to HOME

I have no name!@xxx:/$ export HOME=/tmp

I have no name!@xxx:/$ R

> library(pkgdepends);
> new_pkg_deps("dplyr");
<pkg_dependencies>
+ refs:
  - dplyr
(use `$resolve()` to resolve dependencies)
(use `$solve()` to solve dependencies)

I appreciate your response on this. Thanks so much! Faizal