Skip to content

Commit

Permalink
Error handler for ruby passeger gem not been automatically discovered…
Browse files Browse the repository at this point in the history
… because of a network failure (Vagrant)
  • Loading branch information
brodock committed May 23, 2012
1 parent a61fdde commit 9aacf5c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libraries/chef_rvm_passenger_recipe_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

class Chef
module RVMPassenger

# Exceptions
class GemVersionNotFound < RuntimeError; end

module RecipeHelpers
##
# Sets the version attribute to the most current RubyGems release,
Expand All @@ -31,9 +35,11 @@ def determine_gem_version_if_not_given
require 'rubygems/dependency_installer'

spec = Gem::DependencyInstaller.new.find_gems_with_sources(
Gem::Dependency.new("passenger", '>= 0')).last[0]
Gem::Dependency.new("passenger", '>= 0')).last

raise Chef::RVMPassenger::GemVersionNotFound, "Cannot find any suitable gem version of ruby Passenger. Please specify node[:rvm_passenger][:version] or check if there are any connection problem with the gem sources" if spec.nil?

node.set[:rvm_passenger][:version] = spec.version.to_s
node.set[:rvm_passenger][:version] = spec[0].version.to_s
Chef::Log.debug(%{Setting node['rvm_passenger']['version'] = } +
%{"#{node['rvm_passenger']['version']}"})
end
Expand Down

0 comments on commit 9aacf5c

Please sign in to comment.