Skip to content

Commit

Permalink
Do not load a plugin if it depends on invalid version of Vagrant
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jul 2, 2011
1 parent 46c8bd0 commit 096c8b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@
- Touch the network configuration file for RedHat so that the `sed` works
with host only networking. [GH-381]
- Load prerelease versions of plugins if available.
- Do not load a plugin if it depends on an invalid version of Vagrant.

## 0.7.5 (May 16, 2011)

Expand Down
9 changes: 9 additions & 0 deletions lib/vagrant/plugin.rb
Expand Up @@ -21,6 +21,9 @@ class Plugin
# load path. This file is loaded to kick off the load sequence
# for that plugin.
def self.load!
# Our version is used for checking dependencies
our_version = Gem::Version.create(Vagrant::VERSION)

# RubyGems 1.8.0 deprecated `source_index`. Gem::Specification is the
# new replacement. For now, we support both, but special-case 1.8.x
# so that we avoid deprecation messages.
Expand All @@ -38,6 +41,12 @@ def self.load!
specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs

specs.each do |spec|
# If this gem depends on Vagrant, verify this is a valid release of
# Vagrant for this gem to load into.
vagrant_dep = spec.dependencies.find { |d| d.name == "vagrant" }
next if vagrant_dep && !vagrant_dep.requirement.satisfied_by?(our_version)

# Find a vagrant_init.rb to verify if this is a plugin
file = nil
if Gem::VERSION >= "1.8.0"
file = spec.matches_for_glob("**/vagrant_init.rb").first
Expand Down

0 comments on commit 096c8b2

Please sign in to comment.