jupyter / help

:sparkles: Need some help or have some questions? Please visit our Discourse page.
https://discourse.jupyter.org
291 stars 97 forks source link

Installing Recent R #265

Open psychemedia opened 6 years ago

psychemedia commented 6 years ago

I'm trying to add minimal R support to a container by adding the following to apt.txt:

r-base
r-recommended 

However, this results in an old version of R being installed. To install a more recent version I need to add an additional apt repository - https://cran.r-project.org/bin/linux/ubuntu/README.html .

Is there any way I can do this? I don't seem to have the permissions required?

brettasmi commented 6 years ago

I assume you have moved on from this, but I came across this issue via Google and thought others might do the same. Right now in October 2018, the newest Jupyter Docker images are still using R 3.4.1, so it's still an issue. You can make a custom Dockerfile to get around this problem.

First, a note on permissions. In your Dockerfile, you can set USER root near the top to gain all the permissions you need, but you'll need to switch back at the end with USER $NB_USER

Now onto the R issue. You can add the following lines in your Dockerfile to update R easily:

RUN conda config --add channels r
RUN conda update --all -y

In my case, I had to add RUN conda config --add channels conda-forge before the two lines above to correct some things that adding a newer R channel broke. I ordered as such to give the r channel precedence over every other channel. In sum, my Dockerfile looks something like the following:

FROM jupyter/datascience-notebook
USER root
RUN conda config --add channels conda-forge
RUN conda config --add channels r
RUN conda update --all -y
...lots of other stuff...
USER $NB_USER