miraisolutions / compareWith

RStudio Addins for Enhanced Diff and Merge
55 stars 11 forks source link

Install compareWith from RStudio docker container #31

Closed nfarabullini closed 4 years ago

nfarabullini commented 5 years ago

From @vladdsm

I have started to add this functionality into my docker container stack https://github.com/vladdsm/docker-r-studio Did not manage to let it work...

Instructions on how to install package when using RStudio docker to follow


In order for compareWith to launch Meld inside a containerized RStudio, we need to allow the graphical output from the Docker container to be displayed on the host machine graphical device.

Here is a working example on a Linux host machine (we use rocker/verse to leverage on many pre-installed packages, but the same works with any image from rocker/rstudio up in the Rocker stack). We use the simplest approach based on mapping the DISPLAY environment variable and volume /tmp/.X11-unix when creating the container:

docker run -d -p 8787:8787 \
  -e USER=me -e PASSWORD=robust_password \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix:ro \
  --name rstudio_compareWith_test \
  rocker/verse:3.6.0

R and RStudio typically would not get the DISPLAY environment variable right, hence we need to add it to Renviron

docker exec rstudio_compareWith_test bash -c \
  'echo "DISPLAY=${DISPLAY}" >> /usr/local/lib/R/etc/Renviron'

Then we install Meld by running

docker exec rstudio_compareWith_test bash -c \
  'apt-get update && apt-get install -y --no-install-recommends meld'

It should then be possible to install compareWith inside RStudio via

remotes::install_github("miraisolutions/compareWith")

and use the addins. This can be tested by checking out a project from GitHub, e.g. usethis::create_from_github("miraisolutions/compareWith").

There will most likely be many dbus, GLib and dconf warnings / errors displayed at the R console when running Meld, this is annoying but should not be problematic.

The example above uses the simplest approach to graphical output from containers. See this Rocker issue, this SO answer and this article for some context and alternative, more advanced approaches, especially when user rights and security concerns might be an obstacle to the simplest one.


Cleanup

    docker rm $(docker stop rstudio_compareWith_test)
riccardoporreca commented 5 years ago

@vladdsm, you may want to first try the minimal example we propose above and then see if this approach indeed works for your case, we'll be happy to have your feedback!

@RolandASc, @nfarabullini, we can wait for some feedback and try this out more at our end, and then possibly decide if and how we can incorporate this into the package itself (README, vignette, GitHub Wiki, ...). We could also go for a light-weight approach and add short comment in the README referring to this issue, this is an approach I have seen in quite a few places.

vladdsm commented 5 years ago

unfortunately this minimal example did not work. At the moment of package installation there is an error: "problem with meld installation"

`Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified)

vladdsm commented 5 years ago

these are my steps to install meld and compareWith package in this branch

riccardoporreca commented 5 years ago

@vladdsm, Note that in the minimal example above it is important to run remotes::install_github("miraisolutions/compareWith") from RStudio. Please make sure this is the case. Then, if you still have issues, you can

Note that the setup in your branch probably missing a few key points, I can try to give you a few hints once our minimal example works, to first rule out general problems with your specific setup.

Btw, what is your distro? hostnamectl / lsb_release -a / uname -a

RolandASc commented 4 years ago

@riccardoporreca I am closing this due to inactivity. It might still be a good idea to add a short section about this (with a link) in the README as you have suggested above

riccardoporreca commented 4 years ago

This is actually covered by https://mirai-solutions.ch/techguides/version-stable-r-development-with-docker.html