Skip to content

Commit

Permalink
Show warning message about binstub outside generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Dec 4, 2017
1 parent 5e49f42 commit 623ad64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/bundler/templates/Executable
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>",
Expand Down

0 comments on commit 623ad64

Please sign in to comment.