diff --git a/lib/msfenv.rb b/lib/msfenv.rb index 641e62d504..c3cfdf6461 100644 --- a/lib/msfenv.rb +++ b/lib/msfenv.rb @@ -2,11 +2,25 @@ # Use bundler to load dependencies # -gemfile_base = ::File.expand_path(::File.join(::File.dirname(__FILE__), "..")) -if File.readable?(::File.join(gemfile_base,"Gemfile.local")) - ENV['BUNDLE_GEMFILE'] ||= ::File.join(gemfile_base, "Gemfile.local") -else - ENV['BUNDLE_GEMFILE'] ||= ::File.join(gemfile_base, "Gemfile") +GEMFILE_EXTENSIONS = [ + '.local', + '' +] + +unless ENV['BUNDLE_GEMFILE'] + require 'pathname' + + msfenv_real_pathname = Pathname.new(__FILE__).realpath + root = msfenv_real_pathname.parent.parent + + GEMFILE_EXTENSIONS.each do |extension| + extension_pathname = root.join("Gemfile#{extension}") + + if extension_pathname.readable? + ENV['BUNDLE_GEMFILE'] = extension_pathname.to_path + break + end + end end begin