【问题标题】:Issue installing R package 'devtools' in Docker - getting error installing git2r在 Docker 中安装 R 包“devtools”时出现问题 - 安装 git2r 时出错
【发布时间】:2020-10-21 16:03:50
【问题描述】:

我正在使用 continuumio/miniconda3:latest 基础容器并激活 Conda 环境。 这一切都很好。

当我跑步时: RUN R -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"

我收到一个错误:

configure: Package dependency requirement 'libgit2 >= 0.26.0' could not be satisfied.

  -----------------------------------------------------------------------

   Unable to find the libgit2 library on this system. Building 'git2r'
   using the bundled source of the libgit2 library.

   To build git2r with a system installation of libgit2, please install:
     libgit2-dev   (package on e.g. Debian and Ubuntu)
     libgit2-devel (package on e.g. Fedora, CentOS and RHEL)
     libgit2       (Homebrew package on OS X)
   and try again.

   If the libgit2 library is installed on your system but the git2r
   configuration is unable to find it, you can specify the include and
   lib path to libgit2 with:

   given you downloaded a tar-gz archive:
   R CMD INSTALL git2r-.tar.gz --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'

   or cloned the GitHub git2r repository into a directory:
   R CMD INSTALL git2r/ --configure-vars='INCLUDE_DIR=/path/to/include LIB_DIR=/path/to/lib'

   or download and install git2r in R using
   install.packages('git2r', type='source', configure.vars='LIB_DIR=-L/path/to/libs INCLUDE_DIR=-I/path/to/headers')

   On macOS, another possibility is to let the configuration
   automatically download the libgit2 library from the Homebrew
   package manager with:

   R CMD INSTALL git2r-.tar.gz --configure-vars='autobrew=yes'
   or
   R CMD INSTALL git2r/ --configure-vars='autobrew=yes'
   or
   install.packages('git2r', type='source', configure.vars='autobrew=yes')

  -----------------------------------------------------------------------


configure: Attempting configuration of bundled libgit2
checking size of void*... 8
checking for library containing inflate... no
configure: error: in `/tmp/Rtmpbkmfhr/R.INSTALL8c407eb001/git2r':
configure: error:
  ---------------------------------------------
   The zlib library that is required to build
   git2r was not found.

   Please install:
     zlib1g-dev (package on e.g. Debian and Ubuntu)
     zlib-devel (package on e.g. Fedora, CentOS and RHEL)
   and try again.

   If the zlib library is installed on your
   system but the git2r configuration is
   unable to find it, you can specify the
   include and lib path to zlib with:
   R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers'
  ---------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘git2r’
* removing ‘/opt/conda/envs/r-app/lib/R/library/git2r’

我使用 apt-get install libgit2-dev 在 Dockerfile 的开头安装了 libgit2-dev,它安装了 libgit2 版本 0.27.7。

现在奇怪的是,如果我启动容器并访问它,我可以正常运行 "install.packages('devtools',repos = 'http://cran.us.r-project.org')" 并且它可以工作。

Dockerfile:

FROM continuumio/miniconda3:latest

RUN apt-get update -y; apt-get upgrade -y; \
    apt-get install -y vim ssh libgit2-dev zlib1g-dev \
    build-essential gcc gfortran g++

RUN conda update -n base -c defaults conda
COPY environment.yml environment.yml
RUN conda env create -f environment.yml

RUN echo "source activate r-env" >> ~/.bashrc

ENV PATH /opt/conda/envs/r-env/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

RUN R -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"

环境.yml:

name: r-env
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - r-essentials
  - r-base

【问题讨论】:

    标签: r docker miniconda


    【解决方案1】:

    将 Dockerfile 的最后一行替换为:

    RUN Rscript -e "install.packages('devtools',repos = 'http://cran.us.r-project.org')"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 2015-07-24
      • 1970-01-01
      • 2020-08-02
      • 2013-06-05
      • 2015-05-27
      • 1970-01-01
      相关资源
      最近更新 更多