Skip to content

Instantly share code, notes, and snippets.

@Pimentoso
Created June 4, 2018 15:30
Show Gist options
  • Save Pimentoso/52138350466b2b97a5cfc48ba3bdbaec to your computer and use it in GitHub Desktop.
Save Pimentoso/52138350466b2b97a5cfc48ba3bdbaec to your computer and use it in GitHub Desktop.
# put all of this into boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap'
env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
development_mode = ['', nil, 'development'].include?(env)
# only enable on 'ruby' (MRI), POSIX (darin, linux, *bsd), and >= 2.3.0
enable_cc =
RUBY_ENGINE == 'ruby' &&
RUBY_PLATFORM =~ /darwin|linux|bsd/ &&
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.3.0") &&
!development_mode
cache_dir = ENV['BOOTSNAP_CACHE_DIR'] || 'tmp/cache'
Bootsnap.setup(
cache_dir: cache_dir,
development_mode: development_mode,
load_path_cache: true,
autoload_paths_cache: true, # assume rails. open to PRs to impl. detection
disable_trace: false,
compile_cache_iseq: enable_cc,
compile_cache_yaml: enable_cc
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment