From a00bb7e51c8ea943e4207e47806a7786fbcc8635 Mon Sep 17 00:00:00 2001 From: Kannan Manickam Date: Mon, 31 Mar 2014 11:44:43 -0700 Subject: [PATCH] Fix requiring of rubygems The Rubygem documentation here http://guides.rubygems.org/name-your-gem/ suggests the naming of rubygems. If the name contains dashes (-) the require statements should include forward slashes that replace the dashes. For example, the 'net-ssh' rubygem should have the require statement of ```ruby require 'net/ssh' ``` This simple fix tries to address this problem and falls back to the original require statement if there is a `LoadError`. This will handle cases where some gem author didn't follow the naming convention suggested in the documentation. --- lib/pry/commands/gem_install.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pry/commands/gem_install.rb b/lib/pry/commands/gem_install.rb index c724ac8d..0e98c023 100644 --- a/lib/pry/commands/gem_install.rb +++ b/lib/pry/commands/gem_install.rb @@ -21,6 +21,9 @@ class Pry def process(gem) Rubygem.install(gem) output.puts "Gem `#{ text.green(gem) }` installed." + require_path = gem.split('-').join('/') + require require_path + rescue LoadError require gem end end