Sha256: 4eae6672607554904f7fc3f96867241821f5676fa07c76b6da8f5209be81b0fc

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require "rubygems"
require "rubygems/gem_runner"

module Vagrant
  module Command
    class Gem < Base
      def execute
        # Bundler sets up its own custom gem load paths such that our
        # own gems are never loaded. Therefore, give an error if a user
        # tries to install gems while within a Bundler-managed environment.
        if defined?(Bundler)
          require 'bundler/shared_helpers'
          if Bundler::SharedHelpers.in_bundle?
            raise Errors::GemCommandInBundler
          end
        end

        # If the user needs some help, we add our own little message at the
        # top so that they're aware of what `vagrant gem` is doing, really.
        if @argv.empty? || @argv.include?("-h") || @argv.include?("--help")
          @env.ui.info(I18n.t("vagrant.commands.gem.help_preamble"),
                       :prefix => false)
          puts
        end

        # We just proxy the arguments onto a real RubyGems command
        # but change `GEM_HOME` so that the gems are installed into
        # our own private gem folder.
        ENV["GEM_HOME"] = @env.gems_path.to_s
        ::Gem.clear_paths
        ::Gem::GemRunner.new.run(@argv.dup)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrantup-1.0.1 lib/vagrant/command/gem.rb
vagrantup-1.0.0 lib/vagrant/command/gem.rb
vagrantup-0.9.99.2 lib/vagrant/command/gem.rb
vagrantup-0.9.99.1 lib/vagrant/command/gem.rb
vagrant-1.0.1 lib/vagrant/command/gem.rb
vagrant-1.0.0 lib/vagrant/command/gem.rb