`vagarnt gem` cannot be called within a bundler env

This commit is contained in:
Mitchell Hashimoto 2012-02-06 22:21:01 -05:00
parent d19f7a44e5
commit 4444e7150c
3 changed files with 21 additions and 0 deletions

View File

@ -5,6 +5,16 @@ 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
# 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.

View File

@ -173,6 +173,11 @@ module Vagrant
error_key(:environment_locked)
end
class GemCommandInBundler < VagrantError
status_code(71)
error_key(:gem_command_in_bundler)
end
class HomeDirectoryMigrationFailed < VagrantError
status_code(53)
error_key(:home_dir_migration_failed)

View File

@ -47,6 +47,12 @@ en:
may run at any given time to avoid problems with VirtualBox inconsistencies
occurring. Please wait for the other instance of Vagrant to end and then
try again.
gem_command_in_bundler: |-
You cannot run the `vagrant gem` command while in a bundler environment.
Bundler messes around quite a bit with the RubyGem load paths and gems
installed via `vagrant gem` are excluded by Bundler.
Instead, please include your Vagrant plugins in your Gemfile itself.
guest:
invalid_class: |-
The specified guest class does not inherit from `Vagrant::Guest::Base`.