Skip to content

Instantly share code, notes, and snippets.

@damiann
Created July 26, 2019 16:46
Show Gist options
  • Save damiann/f4659633578af31303982724e658cf3d to your computer and use it in GitHub Desktop.
Save damiann/f4659633578af31303982724e658cf3d to your computer and use it in GitHub Desktop.
Install missing gems
def install_missing_gems(&block)
yield
rescue LoadError => e
gem_name = e.message.split('--').last.strip
install_command = 'gem install ' + gem_name
system(install_command) or exit(1)
Gem.clear_paths
require gem_name
retry
end
install_missing_gems do
require 'ffi-icu'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment