Shiny server Install CentOS 8.1 build - r

I am attempting to do a fresh build of a Shiny server, using CentOS 8. I have been using the instructions on the Shiny server download site.
I have been successful up to the point of installing the Shiny R packages. Using the code on the website
sudo su -
-c "R -e "install.packages('shiny', repos='https://cran.rstudio.com/')"">
I am getting the following error/response: <[root#CP-Shiny]# sudo su - \ -c "R -e "install.packages('shiny', repos='https://cran.rstudio.com/')""
su: user -c does not exist

Does this work?
sudo su - -c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
It escapes the quotes inside quotes using \

Related

How to install r package on server

i am trying to install r package in ubuntu to deploy the app in shiny-server with required version i have tried the below code but it was throwing an error
Error: unexpected '/' in "install.packages(http:/"
Execution halted
Code:
sudo su - -c "R -e \"install.packages("http://cran.r-project.org/src/contrib/Archive/shinydashboard/shinydashboard_0.6.1.tar.gz", repos=NULL)\""
Is there any other way to install this packages in ubuntu
Try:
sudo su - \
-c "R -e \"install.packages('http://cran.r-project.org/src/contrib/Archive/shinydashboard/shinydashboard_0.6.1.tar.gz',
repos=NULL, type ='source')\""

Docker does not find R despite pre-built layers

I create a docker image to run R scripts on a VM server with no access to the internet.
For the first layer I load R and all libraries
Dockerfile1
FROM r-base
## Needed to access R
ENV R_HOME /usr/lib/R
## install required libraries
RUN apt-get update
RUN apt-get -y install libgdal-dev
## install R-packages
RUN R -e "install.packages('dplyr',dependencies=TRUE, repos='http://cran.rstudio.com/')"
...
and create it
docker build -t mycreate_od/libraries -f Dockerfile1 .
Then I use this library layer to load the R script
Dockerfile2
FROM mycreate_od/libraries
## Create directory
RUN mkdir -p /home/analysis/
## Copy files
COPY my_script_dir /home/analysis/
## Run the script
CMD R -e "source('/home/analysis/my_script_dir/main.R')"
Create the analysis layer
docker build -t mycreate_od/analysis -f vault/Dockerfile2 .
On my master VM, this runs and suceeds, but on the fresh VM I get
docker run mycreate_od/analysis
R docker ERROR: R_HOME ('/usr/lib/R') not found - Recherche Google
From a previous bug search I have set the ENV variable in the Docker (see Dockerfile1),
but it looks like docker installs R on some other place.
Thanks to Dirk advice I managed to get it done using r-apt (see Dockerfile below).
The image get then built and can be run without the R_HOME error.
BTW much faster and with a significantly smaller resulting image.
FROM rocker/r-apt:bionic
RUN apt-get update && \
apt-get -y install libgdal-dev && \
apt-get install -y -qq \
r-cran-dplyr \
r-cran-rjson \
r-cran-data.table \
r-cran-crayon \
r-cran-geosphere \
r-cran-lubridate \
r-cran-sp \
r-cran-R.utils
RUN R -e 'install.packages("tools")'
RUN R -e 'install.packages("rgdal", repos="http://R-Forge.R-project.org")'
This is unfortunately a cargo-boat solution, as I am unable to explain why the previous Dockerfile failed.

Error setting up environment on Google Cloud Shell to use Cloud ML

Following instructions from https://cloud.google.com/ml/docs/how-tos/getting-set-up:
Created a project and started the Cloud Shell.
Ran below script to Install required tools and dependencies
curl https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/setup_cloud_shell.sh | bash
Expected outcome >>
"Success! Your environment has the required tools and dependencies." when the script finishes successfully.
Actual outcome >>
+ pip install --user --upgrade 'pillow>=3.4.2' --global-option=build_ext --global-option=--disable-jpeg
/usr/local/lib/python2.7/dist-packages/pip-8.1.1- py2.7.egg/pip/commands/install.py:180: UserWarning: Disabling all use of wheels due to the use of --build-options / --g
lobal-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting pillow>=3.4.2
Using cached Pillow-4.0.0.tar.gz
Collecting olefile (from pillow>=3.4.2)
Using cached olefile-0.43.zip
Installing collected packages: olefile, pillow
Running setup.py install for olefile ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build- KwQqVS/olefile/setup.py';exec(compile(getattr(tokenize, 'op
en', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" build_ext --disable-jpeg install --record /tmp/pip-eOHYKZ-record/install-record.txt --single-vers
ion-externally-managed --compile --user --prefix=:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: option --disable-jpeg not recognized
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build- KwQqVS/olefile/setup.py';exec(compile(getattr(tokenize, 'open', open) (__file__).rea
d().replace('\r\n', '\n'), __file__, 'exec'))" build_ext --disable-jpeg install --record /tmp/pip-eOHYKZ-record/install-record.txt --single-version- externally-managed -
-compile --user --prefix=" failed with error code 1 in /tmp/pip-build- KwQqVS/olefile/
I had the same problem and I solved it.
The error came from Pilow.
First you should install Pillow seperately: (with sudo)
sudo pip install --upgrade pillow
Then you run again the command:
curl https://raw.githubusercontent.com/GoogleCloudPlatform/cloudml-samples/master/tools/setup_cloud_shell.sh | bash
Everything will be ok.
The fix has been pushed to Github, the new version did
pip install --user --upgrade pillow,
which doesn't have the '--disable-jpeg' option. It seems that the new version of Pillow fixed the issue mentioned in Fail during installation of Pillow (Python module) in Linux and removed the option.

Unable to install R/rmr2 on AWS EMR

Having spent around a week trying to install R and rmr2 on AWS-EMR, I am turning to you all for a little help. My bootstrap script is successfully installing R 2.14.1-1~lennycran.0 (thanks to JD Long's blog). When I am trying to install rmr2 I am having the classic dependency problem. Seems I have to install packages like Rcpp, RJSONIO, bitops, digest and 5 more. Because only an older Rcpp works with R 2.14.1, I am downloading a named version and installing it. How old, I don't know - I randomly tried a few versions and 0.8.9 worked. I will make a few more hit-and-trials.
sudo curl -o Rcpp.tar.gz http://cran.us.r-project.org/src/contrib/Archive/Rcpp/Rcpp_0.8.9.tar.gz
sudo R CMD INSTALL Rcpp.tar.gz
Now I am supposed to install the rest of the dependencies (How?)
And eventually rmr2 would be installed. I am using the following script, which, of course fails -
sudo wget --no-check-certificate -o rmr2.tar.qz -S -T 10 -t 5 http://goo.gl/dvBric
sudo R CMD INSTALL rmr2.tar.gz
My question is -
What should be a simple bootstrap script for installing the rest of the dependencies ("RJSONIO", "bitops", "digest", "functional", "stringr", "plyr", "reshape2", "caTools")? Do I have to worry about compatibility of those packages as well?
Here is my complete bootstrap.sh code -
#!/bin/bash
#debian R upgrade
gpg --keyserver pgpkeys.mit.edu --recv-key 06F90DE5381BA480
gpg -a --export 06F90DE5381BA480 | sudo apt-key add -
echo "deb http://streaming.stat.iastate.edu/CRAN/bin/linux/debian lenny-cran/" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get -t lenny-cran install --yes --force-yes r-base r-base-dev
sudo curl -o rmr2.tar.gz http://goo.gl/dvBric
sudo R CMD INSTALL rmr2.tar.gz <<<< Does not go beyond this.
set -e
bucket=muxxx-bisxxx-bucket
path=input.tar.gz
wget -S -T 10 -t 5 http://$bucket.s3.amazonaws.com/$path
mkdir -p /home/hadoop/contents
tar -C /home/hadoop/contents -xzf input.tar.gz
export HADOOP_CMD=/home/hadoop/bin/hadoop
export HADOOP_STREAMING=/home/hadoop/contrib/streaming/hadoop_streaming.jar
/home/hadoop/bin/hadoop fs -mkdir /home/hadoop/contents
/home/hadoop/bin/hadoop fs -put /home/hadoop/contents/* /home/hadoop/contents/
I have not resolved my problem on hand but I got a direction. I added the following line of code in the bootstrap script after R 2.14.1 installation and before rmr2 installation -
sudo Rscript -e 'install.packages(c("rJava", "Rcpp", "RJSONIO", "bitops", "digest", "functional", "stringr", "plyr", "reshape2", "caTools"), repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")'
Currently the bootstrapping process breaks down at plyr, which I guess, is due to older version of Rcpp that I have.
I am closing this post.

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