Install the Ruby agent

Install the Ruby agent on your system.


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

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

Standard Ruby application

Installing the Ruby agent requires 3 commands.

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

echo "gem 'sqreen'" >> Gemfile

Then, in a terminal, use the following commands from your application root directory (the Sqreen token is found on the 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 on non production environments

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

Basic configuration

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

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

export SQREEN_TOKEN=mysecrettoken

The 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, remove the sqreen gem 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 apps (Sinatra), use the standard installation instructions for the Ruby agent and require the Sqreen gem from your application code after Sinatra in the 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). For example in:

  • Stripped down docker containers
  • Old distributions, such as Ubuntu Precise

In the first case, install g++ or clang before running bundle install or gem install. You can remove the C++ compiler immediately afterwards, but you must keep the C++ runtime library (usually libstdc++).

In case of older distributions, you might need to install a newer compiler from separate package repositories.

Travis Precise

To install Sqreen on Travis Precise, you can install GCC 4.8 by adding the below to the .travis.yml file:

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