установите rJava и nloptr на R 3.3.2 внутри docker

#r #docker #rjava

#r #docker #rjava

Вопрос:

внутри rocker/tidyverse:3.3.2 , даже если я установлю r-cran-rjava r-cran-nloptr без ошибок, оба пакета rJAva и nloptr отсутствуют в R. Есть идеи, почему?

смотрите файл Docker ниже :

 FROM rocker/tidyverse:3.3.2

RUN printf "deb http://archive.debian.org/debian/ jessie mainndeb-src http://archive.debian.org/debian/ jessie mainndeb http://security.debian.org jessie/updates mainndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list

RUN apt-get update amp;amp; apt-get install -y --no-install-recommends apt-utils

RUN apt-get -y update amp;amp; apt-get install -y 
   default-jdk  r-cran-rjava  r-cran-nloptr libssh2-1-dev 
RUN R -e "library('rJava')" # Error in library("rJava") : there is no package called ‘rJava’
RUN R -e "library('nloptr')" # Error in library("nloptr") : there is no package called nloptr
 

Спасибо

Ответ №1:

Это связано с тем, что вы устанавливаете двоичные файлы пакетов, подготовленные для последней стабильной версии R, но R, который вы установили, является более старой версией, вы не устанавливаете пакет для версии R, которую хотите использовать.

Ответ №2:

Это решение :

 FROM openjdk:7-slim-jessie
RUN apt-get update
RUN apt-get install -y curl
RUN printf "deb http://deb.debian.org/debian jessie mainndeb-src http://deb.debian.org/debian jessie mainndeb http://security.debian.org/debian-security jessie/updates mainndeb-src http://security.debian.org/debian-security jessie/updates mainn" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get update 
  amp;amp; apt-get install -y --no-install-recommends 
    bash-completion 
    ca-certificates 
    file 
    fonts-texgyre 
    g   
    gfortran 
    gsfonts 
    libblas-dev 
    libbz2-1.0 
    libcurl3 
    libicu52 
    libjpeg62-turbo 
    libopenblas-dev 
    libpangocairo-1.0-0 
    libpcre3 
    libpng12-0 
    libtiff5 
    liblzma5 
    locales 
    make 
    unzip 
    zip 
    zlib1g 
  amp;amp; echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen 
  amp;amp; locale-gen en_US.utf8 
  amp;amp; /usr/sbin/update-locale LANG=en_US.UTF-8 
RUN BUILDDEPS="curl 
 #   default-jdk 
    libbz2-dev 
    libcairo2-dev 
    libcurl4-openssl-dev 
    libpango1.0-dev 
    libjpeg-dev 
    libicu-dev 
    libpcre3-dev 
    libpng-dev 
    libreadline-dev 
    libtiff5-dev 
    liblzma-dev 
    libx11-dev 
    libxt-dev 
    perl 
    tcl8.5-dev 
    tk8.5-dev 
    texinfo 
    texlive-extra-utils 
    texlive-fonts-recommended 
    texlive-fonts-extra 
    texlive-latex-recommended 
    x11proto-core-dev 
    xauth 
    xfonts-base 
    xvfb 
    zlib1g-dev" 
  amp;amp; apt-get install -y --no-install-recommends $BUILDDEPS 
RUN cd tmp/ 
  ## Download source code
  amp;amp; curl -O https://cran.r-project.org/src/base/R-3/R-3.2.3.tar.gz 
  ## Extract source code
  amp;amp; tar -xf R-3.2.3.tar.gz 
  amp;amp; cd R-3.2.3 
  ## Set compiler flags
  amp;amp; R_PAPERSIZE=letter 
    R_BATCHSAVE="--no-save --no-restore" 
    R_BROWSER=xdg-open 
    PAGER=/usr/bin/pager 
    PERL=/usr/bin/perl 
    R_UNZIPCMD=/usr/bin/unzip 
    R_ZIPCMD=/usr/bin/zip 
    R_PRINTCMD=/usr/bin/lpr 
    LIBnn=lib 
    AWK=/usr/bin/awk 
    CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" 
    CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" 
  ## Configure options
  ./configure --enable-R-shlib 
               --enable-memory-profiling 
               --with-readline 
               --with-blas 
               --with-tcltk 
               --disable-nls 
               --with-recommended-packages 
  ## Build and install
  amp;amp; make 
  amp;amp; make install 
  ## Add a default CRAN mirror

RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site 
  ## Add a library directory (for user-installed packages)
  amp;amp; mkdir -p /usr/local/lib/R/site-library 
  amp;amp; chown root:staff /usr/local/lib/R/site-library 
  amp;amp; chmod g wx /usr/local/lib/R/site-library 
  ## Fix library path
  amp;amp; echo "R_LIBS_USER='/usr/local/lib/R/site-library'" >> /usr/local/lib/R/etc/Renviron 
  amp;amp; echo "R_LIBS=${R_LIBS-'/usr/local/lib/R/site-library:/usr/local/lib/R/library:/usr/lib/R/library'}" >> /usr/local/lib/R/etc/Renviron 
  ## install packages from date-locked MRAN snapshot of CRAN
  amp;amp; [ -z "$BUILD_DATE" ] amp;amp; BUILD_DATE=$(TZ="America/Los_Angeles" date -I) || true 
  amp;amp; MRAN=https://mran.microsoft.com/snapshot/${BUILD_DATE} 
  amp;amp; echo MRAN=$MRAN >> /etc/environment 
  amp;amp; export MRAN=$MRAN 
  amp;amp; echo "options(repos = c(CRAN='$MRAN'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site 
  ## Use littler installation scripts
  amp;amp; Rscript -e "install.packages(c('littler', 'docopt'), repo = '$MRAN')" 
  amp;amp; ln -s /usr/local/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r 
  amp;amp; ln -s /usr/local/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r 
  amp;amp; ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r 
  ## Clean up from R source install
  amp;amp; cd / 
  amp;amp; rm -rf /tmp/* 
  amp;amp; apt-get remove --purge -y $BUILDDEPS 
  amp;amp; apt-get autoremove -y 
  amp;amp; apt-get autoclean -y 
amp;amp; rm -rf /var/lib/apt/lists/*
RUN echo "options(repos = c(CRAN='https://mran.microsoft.com/snapshot/2016-10-10'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site




RUN printf "deb http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie mainndeb-src http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie mainndeb http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie-backports mainndeb-src http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie-backports mainn" > /etc/apt/sources.list

#RUN apt-get -y -o Acquire::Check-Valid-Until=false update amp;amp; apt-get install -y 
#    r-cran-rjava  r-cran-nloptr libssh2-1-dev
RUN apt-get -y -o Acquire::Check-Valid-Until=false update
RUN printf "deb http://deb.debian.org/debian jessie mainndeb-src http://deb.debian.org/debian jessie mainndeb http://security.debian.org/debian-security jessie/updates mainndeb-src http://security.debian.org/debian-security jessie/updates mainn" > /etc/apt/sources.list
RUN apt-get -y -o Acquire::Check-Valid-Until=false update
RUN apt-get install -y libxml2-dev 
#RUN apt-get install -y r-cran-xml2 
#RUN apt-get install -y r-base-dev
RUN apt-get install -y libbz2-dev  libicu-dev  liblzma-dev 
#RUN echo "install.packages('rJava', repos='http://www.rforge.net/', configure.args='--disable-Xrs')" | R --no-save
RUN apt-get install -y libnlopt-dev libnlopt-guile0 libnlopt0
RUN R -e "install.packages('xml2')" 
RUN R -e "install.packages('rJava')"    

RUN R -e "install.packages('xml2')" 
RUN R -e "install.packages('ReporteRs')"

RUN R -e "install.packages('nloptr')"