From 4c6673270af3e9003ac6e19dd742d9dec9250ce6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 11 Jul 2011 20:13:19 -0700 Subject: [PATCH] Ruby 1.8 compatibility --- lib/vagrant/environment.rb | 7 +++++-- lib/vagrant/util/counter.rb | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 042a95d17..8d3abcc64 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -324,10 +324,13 @@ module Vagrant return @root_path if defined?(@root_path) root_finder = lambda do |path| - vagrantfile_name.each do |rootfile| - return path if File.exist?(File.join(path.to_s, rootfile)) + # Note: To remain compatible with Ruby 1.8, we have to use + # a `find` here instead of an `each`. + found = vagrantfile_name.find do |rootfile| + File.exist?(File.join(path.to_s, rootfile)) end + return path if found return nil if path.root? || !File.exist?(path) root_finder.call(path.parent) end diff --git a/lib/vagrant/util/counter.rb b/lib/vagrant/util/counter.rb index 75d1fde84..0114202ee 100644 --- a/lib/vagrant/util/counter.rb +++ b/lib/vagrant/util/counter.rb @@ -1,3 +1,5 @@ +require 'thread' + module Vagrant module Util # Atomic counter implementation. This is useful for incrementing