diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-09 09:24:48 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-09 09:24:48 -0700 |
commit | ee889510f82d34b1f911ef886bd63d47c079b6f0 (patch) | |
tree | 4fd5537ca692ddf38c921dc77c0eb16f0853c63e /railties/lib/rails | |
parent | 5654b0a27e35ace26e65e6f6a2a420da8c81583a (diff) | |
parent | ffd899f921b68ccca2f29cfaa9e5759b0de52ed7 (diff) | |
download | rails-ee889510f82d34b1f911ef886bd63d47c079b6f0.tar.gz rails-ee889510f82d34b1f911ef886bd63d47c079b6f0.tar.bz2 rails-ee889510f82d34b1f911ef886bd63d47c079b6f0.zip |
Merge pull request #9843 from indirect/rails_bin
Rails 4 prints help for "rails new" when running "rails console"
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/app_rails_loader.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 44f4d3dabc..c64d1b2552 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 + 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) + 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." + 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 |