forked from hashicorp/vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
107 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters