module Bundler::SharedHelpers

def find_gemfile

def find_gemfile
  given = ENV['BUNDLE_GEMFILE']
  return given if given && !given.empty?
  previous = nil
  current  = File.expand_path(Dir.pwd)
  until !File.directory?(current) || current == previous
    if ENV['BUNDLE_SPEC_RUN']
      # avoid stepping above the tmp directory when testing
      return nil if File.file?(File.join(current, 'bundler.gemspec'))
    end
    # otherwise return the Gemfile if it's there
    filename = File.join(current, 'Gemfile')
    return filename if File.file?(filename)
    current, previous = File.expand_path("..", current), current
  end
end