Search code examples
rdockerrjava

install rJava and nloptr on R 3.3.2 inside docker


inside rocker/tidyverse:3.3.2 even if I install r-cran-rjava r-cran-nloptr without error, both package rJAva and nloptr are missing in R. Any idea why ?

see the Docker file bellow :

FROM rocker/tidyverse:3.3.2

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

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils

RUN apt-get -y update && 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

thanks


Solution

  • This is because you are installing package binaries prepared for the latest stable version of R but the R you have installed is an older version, you are not installing the package for the R version you want to use.