How To Install ruby-yajl on Ubuntu 18.04

In this tutorial we learn how to install ruby-yajl on Ubuntu 18.04. ruby-yajl is Ruby interface to Yajl, a JSON stream-based parser library

Introduction

In this tutorial we learn how to install ruby-yajl on Ubuntu 18.04.

What is ruby-yajl

ruby-yajl is:

Supported features include,

JSON parsing and encoding directly to and from an IO stream (file, socket, etc) or String. Compressed stream parsing and encoding supported for Bzip2, Gzip and Deflate.

Parse and encode multiple JSON objects to and from streams or strings continuously.

JSON gem compatibility API - allows yajl-ruby to be used as a drop-in replacement for the JSON gem

Basic HTTP client (only GET requests supported for now) which parses JSON directly off the response body as it’s being received

There are three methods to install ruby-yajl on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install ruby-yajl Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install ruby-yajl using apt-get by running the following command:

sudo apt-get -y install ruby-yajl

Install ruby-yajl Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install ruby-yajl using apt by running the following command:

sudo apt -y install ruby-yajl

Install ruby-yajl Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install ruby-yajl using aptitude by running the following command:

sudo aptitude -y install ruby-yajl

How To Uninstall ruby-yajl on Ubuntu 18.04

To uninstall only the ruby-yajl package we can use the following command:

sudo apt-get remove ruby-yajl

Uninstall ruby-yajl And Its Dependencies

To uninstall ruby-yajl and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove ruby-yajl

Remove ruby-yajl Configurations and Data

To remove ruby-yajl configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge ruby-yajl

Remove ruby-yajl configuration, data, and all of its dependencies

We can use the following command to remove ruby-yajl configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge ruby-yajl

References

Summary

In this tutorial we learn how to install ruby-yajl package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.