Starting container process caused \”exec: \\\”R\\\”: executable file not found in $PATH\”: unknown”} - r

I installed shinyproxy using docker-compose.
When going to my shiny app, I am running into the error:
Status code: 500
Message: Failed to start container
and when checking into error message I see:
starting container process caused \"exec: \\"R\\": executable file not found in $PATH\": unknown"}
I am not sure to understand what it means.
In case that helps, the last lines of my Shiny Dockerfile are:
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app')"]
and in my application.yml the container-cmd line is
container-cmd: ["R", "-e", "shiny::runApp('/root/app')"]
Do you see any wrong spelling?
Also as an FYI but don't know if that's useful information, I noticed that:
- There is no R folder in my folder: /usr/lib
- And there is no R folder in /usr/bin/.
And I don't understand why.
Thanks for your help !
EDIT1:
I just installed R and now I see R in the /usr/bin/ folder but still nothing in /usr/lib and still same error message.
EDIT2:
I don't understand one thing, I see the R packages being installed in /usr/local/lib/R BUT
I see nothing in this folder after docker-compose up is done:
$ cd /usr/local/lib
$ ls
$
EDIT3:
As requested, I attach below the Dockerfile for my RStudio container and the Dockerfile for Shiny container:
RStudio Dockerfile:
FROM rocker/tidyverse:3.6.1
## Create directories
RUN mkdir -p /rstudio
RUN mkdir -p /rscripts
RUN R -e "install.packages(c('rvest','shiny','DT', 'digest', 'RCurl', 'caTools', 'bitops', 'httr', 'curl', 'stringr', 'mailR', 'xlsx', 'knitr', 'kableExtra' ,'rmarkdown', 'data.table', 'RSelenium'), repos = 'http://cran.us.r-project.org')"
Shiny Dockerfile:
FROM rocker/shiny:3.5.1
RUN apt-get update && apt-get install libcurl4-openssl-dev libv8-3.14-dev -y &&\
mkdir -p /var/lib/shiny-server/bookmarks/shiny &&\
mkdir -p /root/app
# Download and install library
RUN R -e "install.packages(c('mailR', 'shinydashboard', 'shinyjs', 'V8', 'DT', 'shiny', 'rvest', 'dplyr', 'htmltools', 'promises', 'jsonlite', 'data.table', 'rlang', 'xml2', 'digest', 'XML','rmarkdown'))"
# copy the app to the image
COPY app /root/app
COPY Rprofile.site /usr/local/lib/R/etc
# make all app files readable (solves issue when dev in Windows, but building in Ubuntu)
RUN chmod -R 755 /root/app
RUN chmod -R 755 /usr/local/lib/R/etc
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/app')"]

Related

Installing R in a docker container

I'm trying to install in a Ubuntu:20.04 based container miniconda and, using the conda keyword, R:4.05.
The Dockerfile I'm using is this:
FROM ubuntu:20.04
USER root
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get -y install libcurl4-openssl-dev
RUN apt-get install -y wget
RUN mkdir -p ~/miniconda3
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O ~/miniconda3/miniconda.sh
RUN bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
RUN export PATH=~/miniconda3/bin:$PATH
RUN rm -rf ~/miniconda3/miniconda.sh
RUN ~/miniconda3/bin/conda init bash
RUN ~/miniconda3/bin/conda init zsh
RUN ~/miniconda3/bin/conda config --add channels conda-forge
RUN ~/miniconda3/bin/activate
RUN ~/miniconda3/bin/conda install -y -c conda-forge r-base
RUN R -e "install.packages('BiocManager')"
RUN R -e "BiocManager::install('DESeq2')"
From lines 8 to 16 I download miniconda and run it in ~/miniconda3
In line 17:
RUN R -e "install.packages('BiocManager')"
I try to use R and install the BiocManager package from the command line, but I receive this error:
> [16/17] RUN R -e "install.packages('BiocManager')":
#19 2.767 /bin/sh: 1: R: not found
------
executor failed running [/bin/sh -c R -e "install.packages('BiocManager')"]: exit code: 127
I've also tried to start from the official distribution of Rocker, but in this way (the way I've shown you in this post) I would prefer it since I would end up with an image in which I have both miniconda and R.
Can someone help me?
Thanks a lot!
Each RUN command runs in a separate shell, so your export command sets the path, but then the shell exits and the path is reset for the next RUN command.
You also have to use the absolute path. Tilde expansion doesn't work.
Instead of
RUN export PATH=~/miniconda3/bin:$PATH
try
ENV PATH=/root/miniconda3/bin:$PATH

Sparklyr fails to download Spark from apache in Dockerfile

I am trying to create a dockerfile that builds an image from Rocker/tidyverse and include Spark from sparklyr. Previously, on this post: Unable to install spark with sparklyr in Dockerfile, I was trying to figure out why spark wouldn't download from my dockerfile. After playing with it for the past 5 days I think I have found the reason but have no idea how to fix it.
Here is my Dockerfile:
# start with the most up-to-date tidyverse image as the base image
FROM rocker/tidyverse:latest
# install openjdk 8 (Java)
RUN apt-get update \
&& apt-get install -y openjdk-8-jdk
# Install devtools
RUN Rscript -e 'install.packages("devtools")'
# Install sparklyr
RUN Rscript -e 'devtools::install_version("sparklyr", version = "1.5.2", dependencies = TRUE)'
# Install spark
RUN Rscript -e 'sparklyr::spark_install(version = "3.0.0", hadoop_version = "3.2")'
RUN mv /root/spark /opt/ && \
chown -R rstudio:rstudio /opt/spark/ && \
ln -s /opt/spark/ /home/rstudio/
RUN apt-get install unixodbc unixodbc-dev --install-suggests
RUN apt-get install odbc-postgresql
RUN install2.r --error --deps TRUE DBI
RUN install2.r --error --deps TRUE RPostgres
RUN install2.r --error --deps TRUE dbplyr
It has no problem downloading everything up until this line:
RUN Rscript -e 'sparklyr::spark_install(version = "3.0.0", hadoop_version = "3.2")'
Which then gives me the error:
Step 5/11 : RUN Rscript -e 'sparklyr::spark_install(version = "3.0.0", hadoop_version = "3.2")'
---> Running in 739775db8f12
Error in download.file(installInfo$packageRemotePath, destfile = installInfo$packageLocalPath, :
download from 'https://archive.apache.org/dist/spark/spark-3.0.0/spark-3.0.0-bin-hadoop3.2.tgz' failed
Calls: <Anonymous>
Execution halted
ERROR: Service 'rocker_sparklyr' failed to build : The command '/bin/sh -c Rscript -e 'sparklyr::spark_install(version = "3.0.0", hadoop_version = "3.2")'' returned a non-zero code: 1
After doing some research I thought that it was a timeout error, in which case I ran beforehand:
RUN Rscript -e 'options(timeout=600)'
This did not increase the time it took to error out again. I installed everything onto my personal machine through Rstudio and it installed with no problems. I think the problem is specific to docker in that it isn't able to download from https://archive.apache.org/dist/spark/spark-3.0.0/spark-3.0.0-bin-hadoop3.2.tgz
I have found very little documentation on this problem and am relying heavily on this post to figure it out. Thank you in advance to anyone with this knowledge for reaching out.
download the version yourself and then use this function to install
sparklyr::spark_install_tar(tarfile ="~/spark/spark-3.0.1-bin-hadoop3.2.tgz")

R parallel computing and Shiny Server using Dockerfile

I need some help with using parallel computing and the package future with shiny inside a Docker container. When I insert my app in shinyapps.io it works normally, but if I use Docker it gives me the following log error.
[2019-04-22T19:49:24.320] [INFO] shiny-server - Shiny Server v1.5.7.890 (Node.js v8.10.0) [2019-04-22T19:49:24.325] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2019-04-22T19:49:24.440] [INFO] shiny-server - Starting listener on 0.0.0.0:80
[2019-04-22T19:49:29.399] [INFO] shiny-server - Created bookmark state directory: /var/lib/shiny-server/bookmarks
[2019-04-22T19:49:29.401] [INFO] shiny-server - Created user bookmark state directory: /var/lib/shiny-server/bookmarks/shiny
[2019-04-22T19:50:30.486] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
[2019-04-22T19:50:30.488] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
[2019-04-22T19:50:30.489] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
My Dockerfile uses R, shiny-server, a connection to Postgres and sqlite. If I don't use the future it works without errors.
# Install R version 3.5
FROM r-base:3.5.1
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev \
libpq-dev
# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# Install SQLite
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install sqlite3 && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install R packages that are required
# TODO: add further package if you need!
RUN R -e "install.packages(c('RSQLite', 'RPostgres', 'readxl', 'dplyr', 'lubridate', 'DT', 'billboarder', 'shiny', 'future'), repos='http://cran.rstudio.com/')"
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Give permission of READWRITE for the SQLite database
RUN chmod a+rw /srv/shiny-server/db/ /srv/shiny-server/db/*
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
For an example app I've tried a global.R file loading shiny and future and executing something like
library(shiny)
library(future)
plan(multiprocess)
future({print(1)})
with minimal ui.R (like FluidPage()) and server.R (like server <- function(input, output) {}). My bet are that I'm using Windows 7 environment and that causes a confusion in the multiprocess, if so I can just send the app to my IT right now for them to deploy it on the Linux server, OR it's lacking a linux library or something like that, which I couldn't find out yet. Thank you in advance.

Shiny server installation on REHL 7 AWS

I followed these commands to install R and Shiny server on REHL 7 AWS.
sudo yum update
yum install wget gcc pcre-devel libXt-devel cairo-devel pango-devel
pango libpng-devel curl-devel unixODBC-devel python-devel java-1.8.0-
openjdk-devel xz-devel
yum groupinstall "Development tools"
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make -f Makefile-libbz2_so
make clean
make
make -n install
make install
cd ~
wget https://cran.r-project.org/src/base/R-3/R-3.3.2.tar.gz
tar -xzvf R-3.3.2.tar.gz
cd R-3.3.2
./configure --with-readline=no --with-x=no
make
make install
cp -r /usr/local/bin/R /usr/local/sbin/R
cp -r /usr/local/bin/Rscript /usr/local/sbin/Rscript
--Installing R packages
R
install.packages(c('shiny', 'rmarkdown', 'Cairo', 'png', 'rJava',
'RCurl'))
--Changing folder permissions
chmod 777 -R /usr/local/bin
chmod 777 -R /usr/local/sbin
chmod 777 -R /usr/local/lib64/R
chmod 777 -R /usr/local/lib64/R/library
chmod 777 /usr/local/lib64/R/etc/ldpaths
--shiny server installation
wget https://download3.rstudio.org/centos5.9/x86_64/shiny-server-
1.5.1.834-rh5-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.5.1.834-rh5-x86_64.rpm
R CMD javareconf
chmod 777 /usr/local/lib64/R/etc/ldpaths
Everything ran fine with some warnings. But the shiny-server.service file is missing. When I try to execute
systemctl restart shiny-server
it says: Failed to restart shiny-server.service: Unit not found.
I also tried installing the newer version of R (3.4.1) and Shiny server(shiny-server-1.5.3.838-rh5-x86_64.rpm) but I am still getting the same error. This is the message I got when I installed shiny server:
/var/tmp/rpm-tmp.kIBODd: line 62: initctl: command not found
/var/tmp/rpm-tmp.kIBODd: line 65: initctl: command not found
Verifying : shiny-server-1.5.1.834-1.x86_64
1/1
Installed:
shiny-server.x86_64 0:1.5.1.834-1
Also I noticed that shiny-server.service is missing in /etc/systemd/system folder. Has anyone resolved this or knows how to resolve this?
I had the same problem.
As suggested in https://github.com/rstudio/shiny-server/issues/316,
entering these three lines manually solved it for me:
sudo cp /opt/shiny-server/config/systemd/shiny-server.service /etc/systemd/system/
sudo systemctl enable shiny-server
sudo systemctl restart shiny-server

centos AWS shiny server wont resolve

Set up using AWS instance running centOS 6.4 with R and shiny server using my Macbook and trying to figure out what is wrong with it as there are issues with this process
# set up AWS Redhat 6.4 instance (dont forget to download .pem)
# set the .pem file into your ~/.ssh/ folder and make sure you chmod the file
chmod 400 ~/.ssh/myshinypemexample.pem
ssh into machine
ssh -i ~/.ssh/myshinypemexample.pem root#yourPublicDNS
# the first time you run this, just press yes, don't be scared :)
# use ec2-user and log into machine
ssh -i ~/.ssh/myshinypemexample.pem ec2-user#yourPublicDNS
Get the EPEL rpm
wget http://mirror.us.leaseweb.net/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm --test
Import the EPEL GPG key
wget https://www.fedoraproject.org/static/0608B895.txt
sudo mv 0608B895.txt /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Verify that the key has been imported.
rpm -qa gpg*
## You should see a line like this: gpg-pubkey-0608b895-4bd22942
Install the rpm
sudo rpm -ivh epel-release-6-8.noarch.rpm
Install shiny server
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
# this gives error and have to install Rcpp and httr manually
wget http://cran.r-project.org/src/contrib/Rcpp_0.11.1.tar.gz
sudo R CMD INSTALL --build Rcpp_0.11.1.tar.gz
wget http://cran.r-project.org/src/contrib/httpuv_1.2.3.tar.gz
sudo R CMD INSTALL --build httpuv_1.2.3.tar.gz
run shiny server again
sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
Install Shiny Server
wget http://download3.rstudio.org/centos-5.9/x86_64/shiny-server-1.0.0.42-x86_64.rpm
sudo yum install --nogpgcheck shiny-server-1.0.0.42-x86_64.rpm
# test server
sudo status shiny-server
check location of example shiny app
sudo R -e "system.file('examples/01_hello', package='shiny')"
[1] "/usr/lib64/R/library/shiny/examples/01_hello"
#copy example file from R to /srv as Shiny looks for this location to work
sudo cp -R /usr/lib64/R/library/shiny/examples/01_hello /srv/shiny-server/
MYIP:3838 does not resolve. Why?

Resources