Quick Tip - Ensuring required gems and libs are available

So you’re ready to push your code out to your production server farm. You know your plugins will get there safe as they are located in vendor/lib. But what about checking for gems that must be installed? What about checking for third-party ruby extensions (Example: The tclink payment processing ruby extension from TrustCommerce)?

Just add the code below (with your required lib names) and you should be good to go!


# --- [ check that we have all the gems and libs we need ] ---
missing_libs = []
%w( tzinfo tclink mysql money ).each do |lib|
    require lib
  rescue LoadError
    missing_libs << lib
if !missing_libs.empty?
  STDERR.puts '----------------------------------------------------------------'
  STDERR.puts '--- [ The following required libraries could not be loaded ] ---'
  STDERR.puts '----------------------------------------------------------------'
  missing_libs.each{|lib| STDERR.puts "  * #{lib}"}
  exit 1
Comment or question via
FYI: This post was migrated over from another blogging engine. If you encounter any issues please let me know on . Thanks.