`package was installed by an R version with different internals`: Running Shiny server in Docker container

I recently tried to rebuild the Docker container that houses my Shiny app, using the rocker/shiny repository as my base Dockerfile image. That base image gets the latest version of R, which is 3.5.0. Like many others, I ran into issues when trying to install packages after this upgrade. In the build logs for my Docker container, I noticed a lot of these errors:

Error : package was installed by an R version with different internals; it needs to be reinstalled for use with this R version

Which then caused my packages to not install and thus the app crashes upon launching.

What is interesting is that upgrading and installing packages as usual to my local machine gave me no problems; the app runs perfectly fine on my local by using shiny::runApp. I have seen other threads here and elsewhere addressing this issue, but has anyone run into this problem when using a Docker container and using Shiny? It's a Debian base image that the rocker/shiny repository is based off of.

I tried adding install.packages("...") to the top of my Dockerfile, but then it would just choose a different dependency and give the same error message. So at first it was Rcpp, so I added install.packages("Rcpp"), then I went to build and now it said the same error with a package called digest, and so on.

Is there a solution to get all of these dependencies reinstalled and working in the Docker container? The part of my Dockerfile that installs the packages is simply:

RUN Rscript -e "install.packages('RJDBC')"
RUN Rscript -e "install.packages('lubridate')"
RUN Rscript -e "install.packages('devtools')"
RUN Rscript -e "install.packages('ordinal')"
RUN Rscript -e "install.packages('nnet')"
RUN Rscript -e "install.packages('AER')"
RUN Rscript -e "install.packages('emmeans')"
RUN Rscript -e "install.packages('DT')"
RUN Rscript -e "install.packages('dplyr')"
RUN Rscript -e "install.packages('tidyr')"
RUN Rscript -e "install.packages('ggplot2')"
RUN Rscript -e "install.packages('yaml')"
RUN Rscript -e "install.packages('aws.s3')"
RUN Rscript -e "install.packages('lme4')"
RUN Rscript -e "install.packages('lmerTest')"

(Spun-off from this post here: Issues with packages after updating to R 3.5.0)

1 Like

Having the same issue :frowning: did you manage to solve it somehow?

For me the problem turned out to be the installation of rjava with apt-get install r-cran-rjava on top of rocker/shiny, which installed an extra (older) version of R (R 3.2.3) on my docker container (with R 3.5.1). Changing the apt-get install r-cran-rjava line to:

apt-get install -y default-jdk ibicu-dev libbz2-dev liblzma-dev && \
     R -e "install.packages('rJava')" 

Solved the problem.