Giter Club home page Giter Club logo

rstudio-server-conda's Introduction

Howto run Rstudio Server in an Anaconda environment

I usually rely on the conda package manager to manage my environments during development. Thanks to conda-forge and bioconda most R packages are now also available through conda.

Unfortunately, there seems to be no straightforward way to use conda envs in Rstudio server. This is why I came up with the two scripts in this repo.

Installation and usage

1. Prerequisites

2. Disable rstudio server service.

You might need to disable the system-wide Rstudio server service. Due to licensing restrictions of rstudio server community edition, only one rstudio process can run for each user simultaneously.

This is how it works on systemd-based systems:

sudo systemctl disable rstudio-server.service
sudo systemctl stop rstudio-server.service

3. Clone this repo

git clone https://github.com/grst/rstudio-server-conda.git

4. Run rstudio server in the conda env

conda activate my_project
./start_rstudio_server.sh 8787  # use any free port number here. 

You should now be able to connect to rstudio server on the port you specify. If an R Session has previously been running, you'll need to rstart the Rsession now.

Obviously, if your env does not have a version of R installed, this will either not work at all, or fall back to the system-wide R installation.

How it works

  • Rstudio server, can be started in non-daemonized mode by each user individually on a custom port (similar to a jupyter notebook). This instance can then run in a conda environment:
> conda activate my_project
> /usr/lib/rstudio-server/bin/rserver \
   --server-daemonize=0 \
   --www-port 8787 \
   --rsession-which-r=$(which R) \
   --rsession-ld-library-path=$CONDA_PREFIX/lib
  • To avoid additional problems with library paths, also rsession needs to run within the conda environment. This is achieved by wrapping rsession into the rsession.sh script. The path to the wrapped rsession executable can be passed to rserver as command line argument.
rserver # ...
    --rsession-path=rsession.sh
  • When using multiple users a unique secret-cookie-key has to be generated for each user. The path to the secret cookie key can be passed to rserver as a command line parameter.
uuid > /tmp/rstudio-server/${USER}_secure-cookie-key
rserver # ...
  --secure-cookie-key-file /tmp/rstudio-server/${USER}_secure-cookie-key

rstudio-server-conda's People

Contributors

grst avatar

Stargazers

Juan Telleria Ruiz de Aguirre avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.