March 30, 2017 | S. P. T. Krishnan
Recently we came across the need to install the R programming language, specifically version 3.3.2, on Amazon Linux. And at the time of writing this article, Amazon Linux only carries version 3.2.2 . After confirming the non-availability of version 3.3.2 in Amazon’s preview repository; we did some research on our end to install R 3.3.2 on Amazon Linux. In this two-part blog series, we share the process, with the belief that you might have a need for this or any other package that is not available in the Amazon Linux software repositories.
Principle Behind Amazon Linux
Let us start by understanding the design principle behind Amazon Linux. Amazon Linux is an RPM-based distribution, and by looking at the system configuration file “/etc/os-release”, we see that Amazon Linux is based on Red Hat Enterprise Linux (RHEL) , specifically version 6  and Fedora . As documented in , RHEL6 shipped on 10 November 2010 with the latest update, update 8, which shipped on 10 May 2016. The kernel versions that shipped in RHEL6 were between 2.6.32-71 – 2.6.32-642. However, the kernel versions in Amazon Linux is different and much newer, as shown by the results for system command “uname -a”. The following code block shows the results of these two system comments, with the relevant output highlighted using “BOLD ITALICS”.
Using the above information and , we found that the Linux kernel is either from the Fedora 23 update release or the Fedora 24 beta release. This makes Amazon Linux a hybrid Linux distribution. In our view, we see that, Amazon wants to strike a balance between a slow-moving enterprise-class Linux distribution (i.e., RHEL) and fast-moving community-class Linux distribution (i.e., Fedora) by selectively including packages from either of them, as appropriate.
You can install R (and other packages) from source. However, this involves mastery of the build toolchain & process, satisfying prerequisites and more importantly being responsible for keeping the package up-to-date. Taking into consideration security updates and patch lifecycle, we do not recommend a source-based installation as the first choice, especially when the package is available from a well-maintained upstream repository. However, a valid reason for installing from source is that the package in an upstream repository might be out-of-date.
In the last section we will generalize the process so that you can install any package of your interest.
Installing R 3.3.2
As a first step we confirm that the R 3.3.2 package is not installed by default and is not available through the default repositories. This can be achieved using two bash commands. The following code block shows the output of these two bash commands, with the relevant parts highlighted using “BOLD ITALICS”, and were executed on an Amazon Linux Instance on EC2.
The previous terminal output shows that R is not installed and the version we are interested in is not available from the default repositories. Next, we look at the rpm repository setup in the system. This is achieved by looking at the directory “/etc/yum.repos.d”, as shown in the following code block (irrelevant parts redacted with …).
Each of these software repository configuration files contain one or more repositories and is enabled by setting the variable “enabled=1” or disabled by setting the same variable “enabled=0”. We now look into these files to see which of the repositories are enabled/disabled.
We can see that only the “amazon-main” and “amazon-updates” repositories are enabled. We will now enable the “amazon-preview” repository to check if R332 is available in there. The following code block shows that even the “amazon-preview” repository does not carry R332. Check the references  to learn how to enable repos using EPEL as an example. EPEL is a fedora project is called “Extra Packages for Enterprise Linux” and maintains packages for enterprise linux distributions including, but not limited to, RHEL, CentOS, Scientific Linux and Oracle Linux.
We will now restore the default repositories, i.e., disable the “amazon-preview” repository and continue to enable the EPEL repository.
Note: The reason we are enabling one repo at a time is to ensure that there are no package conflicts, as it is possible for different repositories to carry the same package and more commonly different versions of the same package.
We observe two things in the above output. First, there is still no R available from EPEL. This is strange because the packages list of this epel.repo repository carries R332 packages as per the packages list available from . This lead us to wonder why the package is not visible to the “yum” command. Upon further investigation we found that amazon repositories are allocated a higher priority than 3rd party priorities.
We now proceed to increase the priority of EPEL repositories. This can be done by either adding “priority” to EPEL.repo or removing the priority from amazon repositories, thus making them all the same priority. We proceed by adding “priority=10” to the EPEL repo. The following console shows the result.
The above output confirms that R332 is present in the EPEL repository. We will now proceed to install R332 by specifying the exact version as shown in the following command.
The above output shows that some dependencies are not being met by amazon or the EPEL repositories. This came as a surprise to us and set us thinking why would a package like R332 be included in an optional repository but not its prerequisites. In the follow-up post we will show you how to fix this situation by adding 3rd party repositories and selectively enabling only the required packages from those repositories.
Read more about this in part two of the blog series. If you are interested in having our team help you in your projects, please contact us at email@example.com. Also, if you like these kind of problems and want to join our team please contact us at firstname.lastname@example.org or visit us at http://www.reancloud.com/company/careers/.
 Amazon Linux – https://aws.amazon.com/amazon-linux-ami/
 Red Hat Enterprise Linux – https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux
 Fedora version history – https://en.wikipedia.org/wiki/Fedora_version_history
 EPEL – https://fedoraproject.org/wiki/EPEL
 EPEL packages list – https://dl.fedoraproject.org/pub/epel/6/x86_64/
 Missing Packages Error – https://forums.aws.amazon.com/thread.jspa?messageID=262860