require 'rails/app_rails_loader' Rails::AppRailsLoader.exec_app_rails module Rails module AppRailsLoader RUBY = Gem.ruby EXECUTABLES = ['bin/rails', 'script/rails'] ... def self.exec_app_rails original_cwd = Dir.pwd loop do if exe = find_executable contents = File.read(exe) if contents =~ /(APP|ENGINE)_PATH/ exec RUBY, exe, *ARGV break # non reachable, hack to be able to stub exec in the test suit