Install an R package in Dockerfile in Deepnote

884 views Asked by At

I've set up a custom environment with R kernel in Deepnote and I want to use the Dockerfile to install the mosaic package (otherwise I have to install it manually every day and it takes a while). When I add

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

after the IRkernel::installspec line in the Dockerfile, I get this output:

Step #1: > install.packages("mosaic")
Step #1: Installing package into ‘/usr/local/lib/R/site-library’
Step #1: (as ‘lib’ is unspecified)
Step #1: Warning in install.packages("mosaic") :
Step #1:   'lib = "/usr/local/lib/R/site-library"' is not writable
Step #1: Error in install.packages("mosaic") : unable to install packages
Step #1: Execution halted
Step #1: The command '/bin/sh -c R -e 'install.packages("mosaic")'' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
Step #1: 

What am I doing wrong?

1

There are 1 answers

1
Benjamin Christoffersen On BEST ANSWER

The example you link to has a sudo:

RUN sudo apt-get update && \
    sudo apt-get install -y r-base

RUN sudo R -e "install.packages('IRkernel', repos='http://cran.rstudio.com/')"
    ^^^^

You likely need that as well since you get a is not writable message.