From 623ad64b69686ec9331aa9becee8d43b18d1d905 Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Mon, 4 Dec 2017 17:22:53 +0900 Subject: [PATCH] Show warning message about binstub outside generation. Fixes #6149. --- lib/bundler/templates/Executable | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 %>",