Install dependencies on Amazon Linux AMI ec2 instance

This post is only focused on how to install dependencies required by front-end testing tool on Amazon Linux AMI EC2 instance. To setup cypress tool for testing, please refer their official documentation. If you’re just interested to get the dependencies installed on amazon ec2 with AMI (rather then reading the explanation), then jump to this automation part directly!

We recently changed our front end testing tool from Casper to cypress. Check out the features, why we choose cypress!

When I set up the tool (version: 1.4.1) on our build machine which runs on Amazon Linux AMI, I just tried to run it in headless mode. It was griping about one of the missing dependencies XVFB (X virtual framebuffer).

XVFB missing while running test cases using cypress tool

I also checked out the official doc to get work around with the dependencies, but that was not enough. Later I did some search on the web and I found this post which had the similar problem. I took the same approach to resolve the dependencies by using ldd program.

The ldd (list dynamic dependencies) can be used to show you the shared libraries required by any given program.
I already set up the kitchensink example project in the home directory with its dependencies.

So, you will see what are the shared libraries required by cypress tool when you hit the command ldd node_modules/cypress/dist/Cypress/Cypress but we’re only interested to cover missing libraries so we will pipe the command of grep to find not found libraries with the command ldd node_modules/cypress/dist/Cypress/Cypress | grep 'not found'.

$ ldd node_modules/cypress/dist/Cypress/Cypress | grep 'not found' => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found

As you can see, it’s not just XVFB, but there are 14 shared libraries as per the above output which are required by cypress tool. Let’s cover those first, which are easily available on Amazon Linux AMI.

So, let’s install that first, as XVFB easily available on Amazon Linux.

yum -y install Xvfb

After this, If you check again the missing libraries using ldd command:

$ ldd node_modules/cypress/dist/Cypress/Cypress | grep 'not found' => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found => not found

If you give attention closely in the above output, you will notice there are only 12 shared libraries missing now, as XVFB installation step covered two libraries which are libXdamage and libXfixes.

In next step, we will install pango, libXrandr, libXcursor, libcups. ( is provided by package cups-libs, see this thread!)

yum install -y pango pango pango-devel libXrandr libXrandr-devel libXcursor libXcursor-devel cups-libs

You can check the missing libraries at this step with ldd command (ldd node_modules/cypress/dist/Cypress/Cypress | grep 'not found'). But I will just move forward to target libXss. libXss is X11 Screen Saver extension library which is available for rpm based system under the different name libXScrnSaver. This we need to install from centos mirror. To install libXss,

rpm -ivh

To install atk,

rpm -ivh # atk
rpm -ivh # atk-devel

Now, we only have to take care of gtk, gdk, gdk-pixbuf, gconf as per the following output:

$ ldd node_modules/cypress/dist/Cypress/Cypress | grep 'not found' => not found => not found => not found => not found

Before we move ahead, we need to install gcc program to compile the above missing libraries, and we can install those later.

yum install -y gcc

Now, to compile gtk, you need to have other tools and libraries installed on your system, refer this page.

So, first we install gconf (pkgconfig) with its dependencies:

# dependencies
yum install -y libIDL libIDL-devel # orbit required these libs
rpm -ivh
yum install -y gtk-doc indent # orbit-devel required thses libs
rpm -ivh
yum install -y libxml2 libxml2-devel dbus dbus-devel dbus-glib dbus-glib-devel intltool # these libs needs to be installed before compiling gconf
# install gconf from tar
cd /tmp
tar -jxvf GConf-2.32.4.tar.bz2
cd GConf-2.32.4
./configure && make
make install

To install gdk-pixbuf with it’s dependencies(libjpeg, libtiff):

# dependencies
yum install -y libtiff-devel libjpeg-devel
# install gdk-pixbuf from tar
cd /tmp
tar -jxvf gdk-pixbuf-2.24.0.tar.bz2
cd gdk-pixbuf-2.24.0
./configure && make
make install

And now at the final step of gtk+ installation,

# dependencies
yum install -y libXcomposite libXcomposite-devel
cd /tmp
tar -jxvf gtk+-2.24.0.tar.bz2
cd gtk+-2.24.0
# gconf installation path -> PKG_CONFIG_PATH
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure
make # this may take a while :) :)
make install


Now, let’s link the four missing libraries to pre-built Cypress,

cd node_modules/cypress/dist/Cypress/Cypress
ln -PL /usr/local/lib/
ln -PL /usr/local/lib/
ln -PL /usr/local/lib/
ln -PL /usr/local/lib/

and now let’s check if any dependency is missing,

$ ldd Cypress | grep 'not found'

if you see no output then it just worked, YAY!


Now, Let’s verify that cypress is working or not. First, start the server from the directory of cypress-example-kitchensink with command npm start. From another ssh session, go to the directory cypress-example-kitchensink and hit the command cypress run. You should see the output as per the following image nearly at the end of the test.

Cypress kitchen sink example test


I already made a script to automate these installation steps and here it is:

cypress tool dependencies installation script

In the above script, just assign the node_modules directory path in the variable called NODE_MODULES_PATH.

I hope sharing this would help so that someone does not have to search and go through the dependencies installation steps. Thanks!