diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-03-14 13:32:00 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-03-14 13:32:00 -0500 |
commit | 16928c87472d9d89d6bcd018c883da06b7ac62d0 (patch) | |
tree | 1f2c48c4e6ad08a2f0db93fe73e500f86059211d /lib/bundler/version.rb | |
parent | 6b3ec9e4734551c351ff11a519f5ca271dc6a018 (diff) | |
download | bundler-16928c87472d9d89d6bcd018c883da06b7ac62d0.tar.gz |
Ensure Gem.loaded_specs["bundler"].version returns bundler's versionseg-fixup-loaded-gemspec-version
Once RubyGems ships with Bundler as a default spec, if using bundler via
-I, it will still be registered as an activated spec (even if the loaded
features are loaded from the load path and not the default gem). This
hack ensures the versions will always match.
Diffstat (limited to 'lib/bundler/version.rb')
-rw-r--r-- | lib/bundler/version.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 9309eb39e3..35c3896482 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -8,4 +8,17 @@ module Bundler # with other versions of bundler and we are unsure how to # handle this better. VERSION = "1.14.6" unless defined?(::Bundler::VERSION) + + def self.overwrite_loaded_gem_version + begin + require "rubygems" + rescue LoadError + return + end + return unless bundler_spec = Gem.loaded_specs["bundler"] + return if bundler_spec.version == VERSION + bundler_spec.version = Bundler::VERSION + end + private_class_method :overwrite_loaded_gem_version + overwrite_loaded_gem_version end |