diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb index c79c8bf814..7f4ef0d03a 100644 --- a/lib/bundler/cli/info.rb +++ b/lib/bundler/cli/info.rb @@ -40,10 +40,13 @@ module Bundler end def print_gem_path(spec) - path = if spec.name == "bundler" - File.expand_path("../../../..", __FILE__) + if spec.name == "bundler" + path = File.expand_path("../../../..", __FILE__) else - spec.full_gem_path + path = spec.full_gem_path + unless File.directory?(path) + return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}" + end end Bundler.ui.info path diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index df2d5f2824..bf18395ba6 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -41,6 +41,15 @@ RSpec.describe "bundle info" do expect(err).to eq("Could not find gem 'missing'.") end + it "warns if path no longer exists on disk" do + FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2")) + + bundle "info rails --path" + + expect(err).to match(/has been deleted/i) + expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) + end + context "given a default gem shippped in ruby", :ruby_repo do it "prints information about the default gem" do bundle! "info rdoc"