From c6fd1fcc91fa4975664177f7f2254a40deacb500 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 20 Mar 2013 17:16:25 -0700 Subject: rails commands even if bin/rails is a gem stub --- railties/lib/rails/app_rails_loader.rb | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 44f4d3dabc..5697c862ae 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -12,25 +12,35 @@ module Rails exe ||= find_executable_in_parent_path return unless exe - exec RUBY, exe, *ARGV if find_executable - Dir.chdir("..") do - # Recurse in a chdir block: if the search fails we want to be sure - # the application is generated in the original working directory. - exec_app_rails unless cwd == Dir.pwd + if File.read(exe) =~ /(APP|ENGINE)_PATH/ + # This is a Rails-generated binstub, let's use it + exec RUBY, exe, *ARGV if find_executable + Dir.chdir("..") do + # Recurse in a chdir block: if the search fails we want to be sure + # the application is generated in the original working directory. + exec_app_rails unless cwd == Dir.pwd + end + else + # this is a Bundler binstub, so we load the app ourselves + Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd)) + require File.expand_path('../boot', APP_PATH) + puts "Your bin/rails file has been overwritten by Bundler." + puts "To update your bin/rails for Rails 4, please run: `bundle " \ + "config --delete binstubs`, then `rm -rf bin`, then `rake " \ + "rails:update:bin`, then add bin/ to your source control." + require 'rails/commands' end rescue SystemCallError # could not chdir, no problem just return end def self.find_executable - EXECUTABLES.find do |exe| - File.exists?(exe) && File.read(exe) =~ /(APP|ENGINE)_PATH/ - end + EXECUTABLES.find { |exe| File.exists?(exe) } end - def self.find_executable_in_parent_path(path = Pathname.new(Dir.pwd)) + def self.find_executable_in_parent_path(path = Pathname.new(Dir.pwd).parent) EXECUTABLES.find do |exe| - File.exists?(File.join(path, exe)) || !path.root? && find_executable_in_parent_path(path.parent) + File.exists?(exe) || !path.root? && find_executable_in_parent_path(path.parent) end end end -- cgit v1.2.3 From b77bbab25ed90ecccca1f5c23feb641ce1f9ef51 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 27 Mar 2013 20:23:13 -0700 Subject: script/rails could never be from bundler --- railties/lib/rails/app_rails_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 5697c862ae..40524a8089 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -20,7 +20,7 @@ module Rails # the application is generated in the original working directory. exec_app_rails unless cwd == Dir.pwd end - else + elsif exe.match(%r(bin/rails$)) # this is a Bundler binstub, so we load the app ourselves Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd)) require File.expand_path('../boot', APP_PATH) -- cgit v1.2.3 From 99e1a4da99a374d21539013c34e7101298617ff9 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 27 Mar 2013 20:24:04 -0700 Subject: need to delete bin, not binstub, update wording --- railties/lib/rails/app_rails_loader.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 40524a8089..68ba4ecc63 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -24,10 +24,10 @@ module Rails # this is a Bundler binstub, so we load the app ourselves Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd)) require File.expand_path('../boot', APP_PATH) - puts "Your bin/rails file has been overwritten by Bundler." - puts "To update your bin/rails for Rails 4, please run: `bundle " \ - "config --delete binstubs`, then `rm -rf bin`, then `rake " \ - "rails:update:bin`, then add bin/ to your source control." + puts "Rails 4 no longer supports Bundler's --binstub option. You " \ + "will need to disable it and update your bin/rails file.\n" \ + "Please run: `bundle config --delete bin && rm -rf bin`, then " \ + "`rake rails:update:bin` and add the resulting bin/ to git." require 'rails/commands' end rescue SystemCallError -- cgit v1.2.3 From ffd899f921b68ccca2f29cfaa9e5759b0de52ed7 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 30 Mar 2013 13:02:26 -0700 Subject: fix binstub typo --- railties/lib/rails/app_rails_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib/rails') diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 68ba4ecc63..c64d1b2552 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -24,7 +24,7 @@ module Rails # this is a Bundler binstub, so we load the app ourselves Object.const_set(:APP_PATH, File.expand_path('config/application', Dir.pwd)) require File.expand_path('../boot', APP_PATH) - puts "Rails 4 no longer supports Bundler's --binstub option. You " \ + puts "Rails 4 no longer supports Bundler's --binstubs option. You " \ "will need to disable it and update your bin/rails file.\n" \ "Please run: `bundle config --delete bin && rm -rf bin`, then " \ "`rake rails:update:bin` and add the resulting bin/ to git." -- cgit v1.2.3