Skip to content

Commit

Permalink
shell out to run bundler on app generation, see rationale in the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Jun 10, 2011
1 parent 8eb2b51 commit 6c58585
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions railties/lib/rails/generators/app_base.rb
Expand Up @@ -188,13 +188,19 @@ def gem_for_javascript
end

def bundle_command(command)
require 'bundler'
require 'bundler/cli'

say_status :run, "bundle #{command}"
Bundler::CLI.new.send(command)
rescue
say_status :failure, "bundler raised an exception, are you offline?", :red

# We are going to shell out rather than invoking Bundle::CLI.new(command)
# because `rails new` loads the Thor gem and on the other hand bundler uses
# its own vendored Thor, which could be a different version. Running both
# things in the same process is a recipe for a night with paracetamol.
#
# We use backticks and #print here instead of vanilla #system because it
# is easier to silence stdout in the existing test suite this way. The
# end-user gets the bundler commands called anyway, so no big deal.
#
# Thanks to James Tucker for the Gem tricks involved in this call.
print `"#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" #{command}`
end

def run_bundle
Expand Down

0 comments on commit 6c58585

Please sign in to comment.