Installation of the Ruby agent


Installing the Sqreen Ruby agent enables you to monitor the security of your application and block attacks in real-time. Installing Sqreen in your Rails application takes less than a minute:

  • Sign up to Sqreen to create your account
  • Pick up your first application name and language. The name of the application can be the name of the repository, or anything that will help you identify the app in your Sqreen dashboard
  • Follow the procedure detailed below

Standard Rails Application

The installation of the Ruby agent only requires 3 lines of code.

First, in your application root directory, add Sqreen gem in your Gemfile:

# Install Sqreen gem in your Gemfile
echo "gem 'sqreen'" >> Gemfile

Then, in a terminal, type the following commands from your application root directory (the Sqreen token will be provided on Sqreen user interface):

# Install the Sqreen gem from your application directory
bundle install 

# Set the Sqreen token provided from your dashboard from your application directory
echo "token: mysecrettoken" > config/sqreen.yml 

Install the agent outside production environment

Typically you will install the Sqreen Ruby agent in your production environment, but you can create several applications using your Sqreen dashboard, and specifying the environment (development, staging, production). A unique Sqreen token will be provided for each of your applications.

Basic configuration

After installing the agent, your configuration will be stored in the configuration file sqreen.yml. It basically contains your Sqreen token.

Instead of using the Sqreen configuration file sqreen.yml, you can also use SQREEN_TOKEN environment variable to set up your token:

export SQREEN_TOKEN=mysecrettoken 

Sqreen Ruby agent provides flexible configuration settings. Refer to Configuration of the Ruby agent for more detailed information.

Uninstall the agent

To uninstall the Sqreen agent, simply remove the gem sqreen from your Gemfile.


The Sqreen Ruby agent's gem is available on rubygems repository.

Use different Sqreen Applications for different environments

We recommend you to use different Sqreen applications on your different environments: Production, Staging and Development.

Bundler app (Sinatra)

For bundler app (Sinatra), proceed to the standard installation of the Ruby agent and just require the Sqreen gem from your application code after Sinatra.

In your application root directory, add Sqreen gem into your Gemfile:

require 'sinatra'
require 'sqreen'

Linux distributions with no C++11 compiler

Some specific environments lack a C++11 compliant compiler (GCC >= 4.8 or clang >= 3.5). Such a compiler may not be available in:

  • many stripped down docker containers;
  • old distributions, such as Ubuntu Precise.

In the first case, installing g++ or clang is necessary before running bundle install or gem install. The C++ compiler can be removed immediately afterwards, but the C++ runtime library (usually libstdc++) must be kept.

In case of old distributions, it might be necessary to install a newer compiler from separate package repositories.

Travis Precise

In order to install Sqreen on Travis Precise, GCC 4.8 can be installed by adding this to the .travis.yml file:

      - ubuntu-toolchain-r-test
      - g++-4.8
  - CXX=g++-4.8