Installing R packages on Amazon Linux EC2 instance - r

I am learning to use RSelenium in an EC2 instance, and I found this handy guide on doing so - https://rpubs.com/grahamplace/rselenium-ec2 - however the guide focuses on an Ubuntu instance and I am using an Amazon Linux Instance. In order to install RSelenium, the guide says I must externally (outside of R but ssh'd into my EC2 instance) install the packages xml (XML i think, case sensitive) and RCurl. The guide's relevant lines of code are:
sudo apt-get install r-cran-xml
sudo apt-get install r-cran-RCurl
however, since I'm in an Amazon Linux instance, I tried:
sudo yum install r-cran-xml
sudo yum install r-cran-RCurl
for which I get the following error:
No package r-cran-RCurl available.
Error: Nothing to do
Note: I was successful in installing R on my machine (my instance), and I am able to simply type R to launch R in the EC2 instance.
Note2: install.packages('XML') and install.packages('RCurl') with R launched do not work either.
Any help appreciated with this, thanks!

the amazon linux R package has a different name:
sudo yum install -y R
then you tried (in R) install.packages(c('XML','RCurl')), but the installation failed.
as you discovered and describe in the comment below, you needed to install an additional amazon linux package, libxml2-devel, in order to install.packages('XML') successfully.

this is what I get when I run sudo yum install -y R
No package R available.
Error: Nothing to do
R is available in Amazon Linux Extra topic "R3.4"
To use, run
sudo amazon-linux-extras install R3.4
Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras

Related

Installing RStan using Rocker

I would like to be able to install the rstan package from binaries (without compiling from source). This blog post by Dirk Eddelbuettel has some clear instructions that should enable me to do exactly that. However I get the following error message when I try and install RStan. Here are the commands I used.
docker run --rm -ti rocker/r-ubuntu:18.04 bash
apt-get update; apt-get dist-upgrade -y
apt-get install -y r-cran-rstan
This produces the following error message.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
r-cran-rstan : Depends: r-cran-v8 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Installing the R tidyverse package using Dirk's instructions works fine. I am working on a Ubuntu OS within the Windows Subsystem for Linux (WSL-2).
These things can happen -- the best best is to then try
sudo apt install r-cran-v8
which reveals r-cran-node64 is required but not available.
I work much more with 20.04 than 18.04 so I don't what is going on here. I would recommend asking on the r-sig-debian list if anybody else has seen this.
PS And if you try 20.04 instead it works there.

EPEL & Codeready-builder AWS EC2 RHEL8

I am running an EC2 instance with a RHEL8 AMI.
I am looking to install R on the instance and I believe I need the EPEL package and to enable the codeready builder through the following two commands
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf config-manager --set-enabled rhui-codeready-builder-for-rhel-8-rhui-rpms
more info at (https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/)
I can download epel (first line) fine but when I run the second line I get the following:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: No matching repo to modify: rhui-codeready-builder-for-rhel-8-rhui-rpms.
Also when I try to run the following, I get the following:
This system has no repositories available through subscriptions.
and for completeness, this is the error when i try to install R
$sudo yum install -y R
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:52:36 ago on Mon 04 May 2020 01:17:58 AM UTC.
Error:
Problem: package R-3.6.3-1.el8.x86_64 requires R-devel = 3.6.3-1.el8, but none of the providers can be installed
- package R-devel-3.6.3-1.el8.x86_64 requires R-core-devel = 3.6.3-1.el8, but none of the providers can be installed
- conflicting requests
- nothing provides openblas-devel needed by R-core-devel-3.6.3-1.el8.x86_64
- nothing provides texinfo-tex needed by R-core-devel-3.6.3-1.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
Does anyone have any ideas or has solved this same problem?
I worked this out just after writing it...
For anyones reference, it seems AWS had their command written wrongly.
Still download epel package as shown above
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
and instead of the following from AWS website
sudo dnf config-manager --set-enabled rhui-codeready-builder-for-rhel-8-rhui-rpms
You can use
sudo dnf config-manager --set-enabled codeready-builder-for-rhel-8-rhui-rpms
Then go ahead with sudo yum install -y R

How to install newer version of R on Amazon Linux 2

For whatever reason, Amazon moved R to the so-called "Extras Library" so you can't install R using sudo yum install -y R anymore. Instead, you have to do sudo amazon-linux-extras install R3.4. As a result, I can only install R 3.4.3 when the newest stable release is 3.6.1, and so many R libraries can't even be installed because the version is too low. Is there any good and clean way to install the latest version of R and skip Amazon's package manager? Thanks!
Use amazon-linux-extras which installs R4.0.2:
amazon-linux-extras install R4
You may need root:
sudo amazon-linux-extras install R4
I've tried setting up R 3.6.x on a docker container that uses the amazonlinux image. My approach was to get the R source file from the below link and install from source
cd /tmp/
wget https://cloud.r-project.org/src/base/R-3/R-3.6.3.tar.gz
tar -zxf R-3.6.3.tar.gz
cd /tmp/R-3.6.3
./configure --without-libtiff --without-lapack --without-ICU --disable-R-profiling --disable-nls
make
make install
you will need to yum install some dependencies, like 'make', which doesn't seem to come with aws amazonlinux docker image (which i think mirrors the EC2 instance AMI image you are referring to).
The above kind of worked for me in that i had a working R3.6 installation, but it didnt allow me use it with rshiny server, so i'm reverting to the shipped 3.4.3 version.
tl;dr: you'll probably have to manually download the source files and install the desired R version from source, and throw in some build dependencies as well.
Try this on Amazon Linux 2
yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install R
Amazon Linux 2 Image contains extras library that can be used as well. Follow the guide here.
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-install-extras-library-software/
sudo amazon-linux-extras enable R3.4
sudo yum clean metadata && sudo yum install R3.4

Installing OpenCPU on Amazon Linux instance

I have a an Amazon Linux instance which uses R to write a function to do some data analysis. I now want to call this function using a REST API. It seems that OpenCPU can get the job done for me.
I have found links to install OpenCPU on Ubuntu, but is there an easy to way to install it on Amazon Linux instance.
PS: I tried
sudo yum -y install opencpu
sudo yum -y install opencpu-server
It says no such package available.
I managed to get it installed from this script https://github.com/jeroenooms/opencpu-server/blob/master/rpm/buildscript.sh.
We now have rpm packages for CentOS 6 and 7 at https://archive.opencpu.org/

How to install a specific version of nginx on Debian 7?

I did the following to nstall nginx on Debian 7
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo service nginx start
This installed the latest version of nginx , How do I install another version?
Doing sudo apt-get install nginx=1.2 or sudo apt-get install nginx-1.2 does not work. It fails saying version not found?
Older version of Nginx is not available in Debian repository, you need configure Nginx Debian repository http://nginx.org/en/linux_packages.html or find the deb package and install manually.
A distribution of Debian is a set of software packages that was tested to run well together. Every change imposes a risk to break somethign somewhere since that change may not have been prepared for by another software also installed.
When you are for a newever version than what the distributions ships, then a look at the package "tracker" will present an overview of what is currently available, which includes so-called backports to your distribution: https://packages.qa.debian.org/n/nginx.html but indeed the packages directly provided by nginx.org should be just fine. For looks into the past, check out http://snapshot.debian.org/package/nginx/ .

Resources