Troubles installing rstudio server

I'm trying to install rstudio server and I get this error when I try to verify the install:

rstudio-server verify-installation
08 Jul 2018 23:55:05 [rserver] ERROR Unable to determine real path of R script /usr/local/bin/R (system error 2 (No such file or directory)); LOGGED FROM: bool rstudio::core::r_util::{anonymous}::validateRScriptPath(const string&, std::string*) /home/ubuntu/rstudio/src/cpp/core/r_util/REnvironmentPosix.cpp:289
rserver[50]: ERROR Unable to determine real path of R script /usr/local/bin/R (system error 2 (No such file or directory)); LOGGED FROM: bool rstudio::core::r_util::{anonymous}::validateRScriptPath(const string&, std::string*) /home/ubuntu/rstudio/src/cpp/core/r_util/REnvironmentPosix.cpp:289
Unable to determine real path of R script /usr/local/bin/R (system error 2 (No such file or directory))

Any ideas?

Thanks!

How did you install R on that machine? Do you know where your R installation is? (and is it at /usr/local/bin/R ?)

Try running

which R

What's the output?

I created an dockerfile with support for greta and nvidia-docker. This is the dockerfile:

## Based on work by https://github.com/earthlab/dockerfiles/blob/master/r-greta/Dockerfile
## https://github.com/rocker-org/ml
## rocker
##

FROM nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04

MAINTAINER "Ignacio Martinez" ignacio@protonmail.com

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

## Prepare R installation from 
RUN sh -c 'echo "deb https://cloud.r-project.org/bin/linux/ubuntu xenial/" >> /etc/apt/sources.list' \
    && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 

RUN apt-get update \
    && apt-get upgrade -y -q \
    && apt-get install -y --no-install-recommends \
           r-base \
           r-base-dev \
           littler \
           r-cran-littler \
           libxml2-dev \
           libxt-dev \
           libssl-dev \
           libcurl4-openssl-dev \
           imagemagick \
           python-pip \
           libpython2.7 \
	   build-essential \
	   curl \
           libfreetype6-dev \
           libzmq3-dev \
           pkg-config \
           python \
           python-dev \
           rsync \
           software-properties-common \
           unzip \
  && Rscript -e "install.packages(c('littler', 'docopt'), repo = 'https://cloud.r-project.org')" \
  && ln -s /usr/local/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
  && ln -s /usr/local/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
  && ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r \
        && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* \
    && echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >> /etc/R/Rprofile.site 

RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
    python get-pip.py && \
    rm get-pip.py

RUN pip --no-cache-dir install \
        ipykernel \
        jupyter \
        matplotlib \
        numpy \
        scipy \
        && \
    python -m ipykernel.kernelspec

RUN install2.r --error \
    devtools  
    
RUN R -e "devtools::install_github('rstudio/tensorflow')"
RUN R -e "devtools::install_github('rstudio/keras')"

RUN install2.r --error \
    devtools \
    bayesplot \
    DiagrammeR \
    greta \
    rgexf \
    XML \
    tidyverse 

RUN pip install virtualenv

## Need to configure non-root user for RStudio
RUN useradd rstudio \
  && echo "rstudio:rstudio" | chpasswd \
	&& mkdir /home/rstudio \
	&& chown rstudio:rstudio /home/rstudio \
	&& addgroup rstudio staff

USER rstudio

RUN R -e "tensorflow::install_tensorflow(version = 'gpu')"

USER root

and this is an example that shows that that dockerfile works:

ignacio@ignacio-XPS-8930:~/docker/r$ nvidia-docker build -t r-gpu .
ignacio@ignacio-XPS-8930:~/docker/r$ nvidia-docker run -it r-gpu bash
root@46f38776714a:/# su rstudio
rstudio@46f38776714a:/$ R

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> x <- iris$Petal.Length
> y <- iris$Sepal.Length
> library(greta)

Attaching package: 'greta'

The following objects are masked from 'package:stats':

    binomial, poisson

The following objects are masked from 'package:base':

    %*%, backsolve, beta, colMeans, colSums, diag, forwardsolve, gamma,
    rowMeans, rowSums, sweep

> int <- normal(0, 5)
> coef <- normal(0, 3)
> sd <- lognormal(0, 3)
> mean <- int + coef * x
> distribution(y) <- normal(mean, sd)
> m <- model(int, coef, sd)
> draws <- mcmc(m, n_samples = 1000)
    warmup ====================================   100/100 | eta:  0s          
  sampling ==================================== 1000/1000 | eta:  0s          

> summary(draws)      

Iterations = 1:1000
Thinning interval = 1 
Number of chains = 1 
Sample size per chain = 1000 

1. Empirical mean and standard deviation for each variable,
   plus standard error of the mean:

       Mean      SD  Naive SE Time-series SE
int  4.3058 0.07607 0.0024056      0.0020345
coef 0.4093 0.01762 0.0005573      0.0004651
sd   0.4086 0.02481 0.0007846      0.0006230

2. Quantiles for each variable:

       2.5%    25%    50%    75%  97.5%
int  4.1532 4.2547 4.3042 4.3534 4.4565
coef 0.3740 0.3971 0.4099 0.4210 0.4430
sd   0.3626 0.3913 0.4075 0.4245 0.4612

Alas, when i tried to create a second dockerfile using the rocker studio as base, it did not work. This is the second dockerfile:

FROM r-gpu

ARG RSTUDIO_VERSION
## Comment the next line to use the latest RStudio Server version by default
#ENV RSTUDIO_VERSION=${RSTUDIO_VERSION:-1.1.447}
ENV PATH=/usr/lib/rstudio-server/bin:$PATH

## Download and install RStudio server & dependencies
## Attempts to get detect latest version, otherwise falls back to version given in $VER
## Symlink pandoc, pandoc-citeproc so they are available system-wide
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    git \
    libedit2 \
    psmisc \
    python-setuptools \
    sudo \
    wget \
  && RSTUDIO_LATEST=$(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-server/current.ver) \
  && [ -z "$RSTUDIO_VERSION" ] && RSTUDIO_VERSION=$RSTUDIO_LATEST || true \
  && wget -q http://download2.rstudio.org/rstudio-server-${RSTUDIO_VERSION}-amd64.deb \
  && dpkg -i rstudio-server-${RSTUDIO_VERSION}-amd64.deb \
  && rm rstudio-server-*-amd64.deb \
  ## Symlink pandoc & standard pandoc templates for use system-wide
  && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc /usr/local/bin \
  && ln -s /usr/lib/rstudio-server/bin/pandoc/pandoc-citeproc /usr/local/bin \
  && git clone https://github.com/jgm/pandoc-templates \
  && mkdir -p /opt/pandoc/templates \
  && cp -r pandoc-templates*/* /opt/pandoc/templates && rm -rf pandoc-templates* \
  && mkdir /root/.pandoc && ln -s /opt/pandoc/templates /root/.pandoc/templates \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/ \
  && mkdir -p /usr/local/lib/R/etc \
  ## RStudio wants an /etc/R, will populate from $R_HOME/etc
  && mkdir -p /etc/R \
  ## Write config files in $R_HOME/etc
  && echo '\n\
    \n# Configure httr to perform out-of-band authentication if HTTR_LOCALHOST \
    \n# is not set since a redirect to localhost may not work depending upon \
    \n# where this Docker container is running. \
    \nif(is.na(Sys.getenv("HTTR_LOCALHOST", unset=NA))) { \
    \n  options(httr_oob_default = TRUE) \
    \n}' >> /usr/local/lib/R/etc/Rprofile.site \
  && echo "PATH=${PATH}" >> /usr/local/lib/R/etc/Renviron \
  ## Prevent rstudio from deciding to use /usr/bin/R if a user apt-get installs a package
  &&  echo 'rsession-which-r=/usr/local/bin/R' >> /etc/rstudio/rserver.conf \
  ## use more robust file locking to avoid errors when using shared volumes:
  && echo 'lock-type=advisory' >> /etc/rstudio/file-locks \
  ## configure git not to request password each time
  && git config --system credential.helper 'cache --timeout=3600' \
  && git config --system push.default simple \
  ## Set up S6 init system
  && wget -P /tmp/ https://github.com/just-containers/s6-overlay/releases/download/v1.11.0.1/s6-overlay-amd64.tar.gz \
  && tar xzf /tmp/s6-overlay-amd64.tar.gz -C / \
  && mkdir -p /etc/services.d/rstudio \
  && echo '#!/usr/bin/with-contenv bash \
           \n exec /usr/lib/rstudio-server/bin/rserver --server-daemonize 0' \
           > /etc/services.d/rstudio/run \
   && echo '#!/bin/bash \
           \n rstudio-server stop' \
           > /etc/services.d/rstudio/finish

COPY userconf.sh /etc/cont-init.d/userconf

## running with "-e ADD=shiny" adds shiny server
COPY add_shiny.sh /etc/cont-init.d/add

COPY pam-helper.sh /usr/lib/rstudio-server/bin/pam-helper

EXPOSE 8787

## automatically link a shared volume for kitematic users
VOLUME /home/rstudio/kitematic

CMD ["/init"]
ignacio@ignacio-XPS-8930:~$ nvidia-docker run -it r-gpu bash
root@318fc02c6fa3:/# su rstudio
rstudio@318fc02c6fa3:/$ which R
/usr/bin/R
rstudio@318fc02c6fa3:/$ exit
exit
root@318fc02c6fa3:/# which R
/usr/bin/R
root@318fc02c6fa3:/# 

Thanks for the help!

1 Like

I was able to solve this problem by adding this line to my dockerfile:

RUN ln /usr/bin/R /usr/local/bin/R

and changing the last line to:

CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0", "--server-app-armor-enabled=0"]

I have everything working but for some reason the default password does not change when I run:

nvidia-docker run -d --restart=always  -p 8787:8787 --name="rstudio-gpu" -e PASSWORD='MYSUPERSECRETPASSWORD!!' rstudio-gpu