---
title: "Rails 5.2 adds bootsnap to the app to speed up boot time"
description:
  "Rails 5.2 adds bootsnap gem to the Gemfile of newly created app so as to
  speed up boot time"
canonical_url: "https://www.bigbinary.com/blog/rails-5-2-adds-bootsnap-to-the-app-to-speed-up-boot-time"
markdown_url: "https://www.bigbinary.com/blog/rails-5-2-adds-bootsnap-to-the-app-to-speed-up-boot-time.md"
---

# Rails 5.2 adds bootsnap to the app to speed up boot time

Rails 5.2 adds bootsnap gem to the Gemfile of newly created app so as to speed
up boot time

- Author: Prathamesh Sonpatki
- Published: January 1, 2018
- Categories: Rails 5.2, Rails

Rails 5.2 beta 1 was recently
[released](http://weblog.rubyonrails.org/2017/11/27/Rails-5-2-Active-Storage-Redis-Cache-Store-HTTP2-Early-Hints-Credentials/).

If we generate a new Rails app using Rails 5.2, we will see bootsnap gem in the
Gemfile. [bootsnap](https://github.com/Shopify/bootsnap) helps in reducing the
boot time of the app by caching expensive computations.

In a new Rails 5.2 app, `boot.rb` will contain following content:

```ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

if %w[s server c console].any? { |a| ARGV.include?(a) }
  puts "=> Booting Rails"
end
```

This sets up bootsnap to start in all environments. We can toggle it per
environment as required.

This works out of the box and we don't have do to anything for the new app.

If we are upgrading an older app which already has bootsnap, then we need to
make sure that we are using bootsnap >= 1.1.0 because new Rails apps ship with
that version constraint.

If the app doesn't contain the bootsnap gem already then we will need to add it
manually since `rails app:update` task adds the `bootsnap/setup` line to
`boot.rb` regardless of its presence in the Gemfile.

## Links

- [Human page](https://www.bigbinary.com/blog/rails-5-2-adds-bootsnap-to-the-app-to-speed-up-boot-time)
