diff options
Diffstat (limited to 'lib/bundler/plugin.rb')
| -rw-r--r-- | lib/bundler/plugin.rb | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 588fa79be8..faca6bea53 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -113,7 +113,7 @@ module Bundler return if definition.dependencies.empty? - plugins = definition.dependencies.map(&:name).reject {|p| index.installed? p } + plugins = definition.dependencies.map(&:name) installed_specs = Installer.new.install_definition(definition) save_plugins plugins, installed_specs, builder.inferred_plugins @@ -195,7 +195,7 @@ module Bundler @sources[name] end - # @param [Hash] The options that are present in the lock file + # @param [Hash] The options that are present in the lockfile # @return [API::Source] the instance of the class that handles the source # type passed in locked_opts def from_lock(locked_opts) @@ -220,7 +220,7 @@ module Bundler # # @param [String] event def hook(event, *args, &arg_blk) - return unless Bundler.feature_flag.plugins? + return unless Bundler.settings[:plugins] unless Events.defined_event?(event) raise ArgumentError, "Event '#{event}' not defined in Bundler::Plugin::Events" end @@ -253,10 +253,13 @@ module Bundler # @param [Array<String>] names of inferred source plugins that can be ignored def save_plugins(plugins, specs, optional_plugins = []) plugins.each do |name| - next if index.installed?(name) - spec = specs[name] + # It's possible that the `plugin` found in the Gemfile don't appear in the specs. For instance when + # calling `BUNDLE_WITHOUT=default bundle install`, the plugins will not get installed. + next if spec.nil? + next if index.up_to_date?(spec) + save_plugin(name, spec, optional_plugins.include?(name)) end end @@ -342,7 +345,26 @@ module Bundler # done to avoid conflicts path = index.plugin_path(name) - Gem.add_to_load_path(*index.load_paths(name)) + paths = index.load_paths(name) + invalid_paths = paths.reject {|p| File.directory?(p) } + + if invalid_paths.any? + Bundler.ui.warn <<~MESSAGE + The following plugin paths don't exist: #{invalid_paths.join(", ")}. + + This can happen if the plugin was installed with a different version of Ruby that has since been uninstalled. + + If you would like to reinstall the plugin, run: + + bundler plugin uninstall #{name} && bundler plugin install #{name} + + Continuing without installing plugin #{name}. + MESSAGE + + return + end + + Gem.add_to_load_path(*paths) load path.join(PLUGIN_FILE_NAME) |
