allow uninstalling gems with bundler

Fixes #2450
This commit is contained in:
Pier-Hugues Pellerin 2015-01-27 15:25:53 -05:00 committed by Jordan Sissel
parent e7d617f703
commit ccb98bc843
3 changed files with 36 additions and 11 deletions

View file

@ -1,6 +1,25 @@
require 'bundler'
module Bundler
class SpecSet
# Usually Bundler's SpecSet is a read only/created once database
# I am modifying this behavior to allow `Gem` to uninstall gems.
def delete(key)
value = @specs.delete(key)
reset_state!
value
end
def delete_if(&block)
@specs.delete_if(&block)
reset_state!
end
def reset_state!
@lookup = nil
@sorted = nil
end
end
class RubygemsIntegration
# When you call Bundler#setup it will bootstrap
# a new rubygems environment and wipe all the existing

View file

@ -1,11 +1,12 @@
require "logstash/namespace"
require "logstash/errors"
require 'clamp'
require 'logstash/pluginmanager/install'
require 'logstash/pluginmanager/uninstall'
require 'logstash/pluginmanager/list'
require 'logstash/pluginmanager/update'
require 'logstash/pluginmanager/util'
require "logstash/pluginmanager/install"
require "logstash/pluginmanager/uninstall"
require "logstash/pluginmanager/list"
require "logstash/pluginmanager/update"
require "logstash/pluginmanager/util"
require "clamp"
class LogStash::PluginManager::Main < Clamp::Command

View file

@ -1,10 +1,11 @@
require "logstash/namespace"
require "logstash/logging"
require "logstash/errors"
require 'clamp'
require 'logstash/pluginmanager'
require 'logstash/pluginmanager/util'
require 'rubygems/uninstaller'
require "logstash/environment"
require "logstash/pluginmanager"
require "logstash/pluginmanager/util"
require "rubygems/uninstaller"
require "clamp"
class LogStash::PluginManager::Uninstall < Clamp::Command
@ -12,11 +13,15 @@ class LogStash::PluginManager::Uninstall < Clamp::Command
public
def execute
::Gem.configuration.verbose = false
puts ("Validating removal of #{plugin}.")
#
# TODO: This is a special case, Bundler doesnt allow you to uninstall 1 gem.
# Bundler will only uninstall the gems if they dont exist in his Gemfile.lock
# (source of truth)
#
unless gem_data = LogStash::PluginManager::Util.logstash_plugin?(plugin)
$stderr.puts ("Trying to remove a non logstash plugin. Aborting")
return 99