diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable index 9289debc262..997c59ea16a 100755 --- a/lib/bundler/templates/Executable +++ b/lib/bundler/templates/Executable @@ -8,8 +8,15 @@ # this file is here to facilitate running it. # +def bundle_stub?(path) + return false unless File.file?(path) + return true if File.read(path, 150) =~ /This file was generated by Bundler/ + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") +end + bundle_binstub = File.expand_path("../bundle", __FILE__) -load(bundle_binstub) if File.file?(bundle_binstub) +load(bundle_binstub) if bundle_stub?(bundle_binstub) require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",