rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
314 stars 63 forks source link

error: [ENOENT] Failed to make directory '//.cache/pins' #705

Closed nick-youngblut closed 1 year ago

nick-youngblut commented 1 year ago

Issue

Trying to load the pins package via library("pins") results in the error:

Error: package or namespace load failed for ‘pins’:
 .onLoad failed in loadNamespace() for 'pins', details:
  call: NULL
  error: [ENOENT] Failed to make directory '//.cache/pins': no such file or directory
Execution halted

The package is assuming that .cache/pins exists, but it does not in the Docker container from which the code is run. I'm not sure what's going on with the // in '//.cache/pins'.

Reprex

Dockerfile:

FROM rocker/r-ver:4.2.1
MAINTAINER Nicholas Youngblut, Federation Bio, Inc.

# Install R dependencies
RUN install2.r --ncpus 4 --error \
  argparse dplyr tidyr glue DBI RPostgres \
  httr aws.s3 aws.signature rsconnect pins qs && \
  rm -rf /tmp/downloaded_packages

devcontainer:

{
    "name": "nfcore",
    "image": "nfcore/gitpod:2.7.1",
    "postCreateCommand": "bash .devcontainer/setup.sh",
    "remoteUser": "gitpod",
    "customizations": {
        "vscode": {
            "settings": {
                "python.defaultInterpreterPath": "/opt/conda/bin/python",
                "python.linting.enabled": true,
                "python.linting.pylintEnabled": true,
                "python.formatting.autopep8Path": "/opt/conda/bin/autopep8",
                "python.formatting.yapfPath": "/opt/conda/bin/yapf",
                "python.linting.flake8Path": "/opt/conda/bin/flake8",
                "python.linting.pycodestylePath": "/opt/conda/bin/pycodestyle",
                "python.linting.pydocstylePath": "/opt/conda/bin/pydocstyle",
                "python.linting.pylintPath": "/opt/conda/bin/pylint"
            },
            "extensions": ["ms-python.python", "ms-python.vscode-pylance", "REditorSupport.r", "EditorConfig.EditorConfig",
                           "codezombiech.gitignore", "Gruntfuggly.todo-tree", "ms-vsliveshare.vsliveshare",
                           "nextflow.nextflow", "redhat.vscode-yaml", "streetsidesoftware.code-spell-checker"]
        }
    },
    "features": {
        "ghcr.io/devcontainers/features/docker-in-docker:2": {
            "version": "latest"
        },
        "ghcr.io/devcontainers/features/aws-cli:1": {
            "version": "latest"
        }
    }
}

R code:

#!/usr/bin/env Rscript

# library
suppressPackageStartupMessages(library("argparse"))
suppressPackageStartupMessages(library("dplyr"))
suppressPackageStartupMessages(library("tidyr"))
suppressPackageStartupMessages(library("rsconnect"))
suppressPackageStartupMessages(library("pins"))
suppressPackageStartupMessages(library("qs"))
nick-youngblut commented 1 year ago

I added to mkdir -p /.cache/pins to my RUN command in my docker file, which just changed the error:

Error: package or namespace load failed for ‘pins’:
 .onLoad failed in loadNamespace() for 'pins', details:
  call: NULL
  error: [EACCES] Failed to make directory '//.cache/pins/local': permission denied

...so I had to open up permissions for /.cache/.

Maybe a vignette on using pins with Docker (& Rocker) could be helpful.

juliasilge commented 1 year ago

Thanks for reporting your problems @nick-youngblut!

I was trying to reproduce the problem with my typical Docker workflow. First I did this to generate an renv.lock:

renv::snapshot(
  project = NULL,
  lockfile = "renv.lock",
  packages = "pins",
  prompt = FALSE
)

Then I build this Dockerfile:

FROM rocker/r-ver:4.2.1
ENV RENV_CONFIG_REPOS_OVERRIDE https://packagemanager.rstudio.com/cran/latest

RUN apt-get update -qq && apt-get install -y --no-install-recommends \
  libcurl4-openssl-dev \
  libssl-dev \
  make \
  && apt-get clean

COPY renv.lock renv.lock
RUN Rscript -e "install.packages('renv')"
RUN Rscript -e "renv::restore()"
RUN Rscript -e "library(pins)"

That ran without error and then I could do docker run --rm -ti pins-example and run pins in the container.

I also tried this Dockerfile and it also worked fine for me:

FROM rocker/r-ver:4.2.1
ENV RENV_CONFIG_REPOS_OVERRIDE https://packagemanager.rstudio.com/cran/latest

RUN install2.r pins

If you are able to create a minimal example that shows the problem you were experiencing with pins and Docker, we would be happy to check it out!

nick-youngblut commented 1 year ago

You will probably need to use VS Code with a devcontainer (as shown above) to reproduce the issue.

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.