Try catch for loading gems

Hey,

I have this in my environment.rb file for requiring gems

require ‘action_mailer’
require ‘sentry’
require ‘money’
require ‘active_merchant’
require ‘pdf/writer’
require ‘pdf/simpletable’
require ‘csv’
require ‘tzinfo/timezone’
require ‘TzForSelect’
require ‘encryption’
require ‘rexml/document’
require ‘rubygems’
require ‘RMagick’
require ‘scoped_access’

But when i do a clean install of my pc, i need to install these gems
again. Sometimes i forget that :stuck_out_tongue: And i get the project doesnt want to
start. So i want something like this if it is possible. For each gem
btw…

try
require ‘sentry’
catch
put “The sentry gem must be installed”
end

I dont know the code for this, and if it is even possible??

Can somebody help me?

Thx
N.

Try:

begin
require “lib”
rescue LoadError
logger.error “lib gem must be installed”
end

Another solution is to put all your installed gems in your vendor
directory.

Bruno C. wrote:

Try:

begin
require “lib”
rescue LoadError
logger.error “lib gem must be installed”
end

Another solution is to put all your installed gems in your vendor
directory.

It worked!

Thx. :wink: