class Bundler::CLI

def exec(*)

def exec(*)
  ARGV.delete("exec")
  # Set PATH
  paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
  paths.unshift "#{Bundler.bundle_path}/bin"
  ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
  # Set BUNDLE_GEMFILE
  ENV["BUNDLE_GEMFILE"] = Bundler::SharedHelpers.default_gemfile.to_s
  # Set RUBYOPT
  rubyopt = [ENV["RUBYOPT"]].compact
  if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
    rubyopt.unshift "-rbundler/setup"
    rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
    ENV["RUBYOPT"] = rubyopt.join(' ')
  end
  begin
    # Run
    Kernel.exec *ARGV
  rescue Errno::EACCES
    Bundler.ui.error "bundler: not executable: #{ARGV.first}"
  rescue Errno::ENOENT
    Bundler.ui.error "bundler: command not found: #{ARGV.first}"
    Bundler.ui.warn  "Install missing gem binaries with `bundle install`"
  end
end