几天以来,我一直在docker镜像构建期间安装R软件包时遇到问题:

> install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://mran.microsoft.com/snapshot/2018-10-25/src/contrib:
  cannot open URL 'https://mran.microsoft.com/snapshot/2018-10-25/src/contrib/PACKAGES'
>
>
Warning message:
package ‘devtools’ is not available (for R version 3.4.4)

这是我的Dockerfile:
FROM rocker/rstudio-stable:3.4.4

MAINTAINER Tazovsky

# system libraries of general use
RUN apt-get update && apt-get install -y \
    sudo \
    pandoc \
    pandoc-citeproc \
    pkg-config \
    libnlopt-dev \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libgsl-dev \
    libssl-dev \
    libssh2-1-dev \
    libssl1.0.0 \
    libxml2-dev \
    openssl

RUN apt-get update && apt-get install -y \
    libmpfr-dev

RUN apt-get install libcurl4-openssl-dev -y

# install java
RUN apt-get update && apt-get install -y openjdk-8-jdk openjdk-8-jre
RUN R CMD javareconf

# r-java
RUN apt-get install r-cran-rjava -y

RUN R -e 'install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")'

我敢肯定它能早一点工作(几周前)。

此外,我检查了命令
install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")
在本地,它的工作原理。

我还尝试通过运行添加CA证书:

本地:
openssl genrsa -des3 -out myCA.key 2048
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem

Dockerfile中:
CP myCA.pem /tmp/myCA.pem
RUN cd tmp && \
    openssl x509 -in myCA.pem -inform PEM -out myCA.crt && \
    cp myCA.crt /usr/local/share/ca-certificates/myCA.crt && \
    update-ca-certificates && \
    rm -rf /tmp/*

但这没有帮助。

知道发生了什么吗?

最佳答案

您可以尝试进行更改(对我有用)

install.packages("devtools", repos = "https://mran.microsoft.com/snapshot/2018-10-25")


install.packages("devtools", repos = "http://cran.rstudio.com/")

07-25 21:52