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 5, 2017
1 parent 030a9c5 commit 1843abd
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 @@ -12,8 +12,15 @@ require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
Pathname.new(__FILE__).realpath)

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 "rubygems"
require "bundler/setup"
Expand Down

0 comments on commit 1843abd

Please sign in to comment.