Browse files

shell out to run bundler on app generation, see rationale in the comment

  • Loading branch information...
1 parent 8eb2b51 commit 6c58585ff5b667de4f29860e4b06e743e0614891 @fxn fxn committed Jun 10, 2011
Showing with 12 additions and 6 deletions.
  1. +12 −6 railties/lib/rails/generators/app_base.rb
18 railties/lib/rails/generators/app_base.rb
@@ -188,13 +188,19 @@ def gem_for_javascript
def bundle_command(command)
- require 'bundler'
- require 'bundler/cli'
say_status :run, "bundle #{command}"
- rescue
- say_status :failure, "bundler raised an exception, are you offline?", :red
+ # We are going to shell out rather than invoking
+ # 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}`
def run_bundle

0 comments on commit 6c58585

Please sign in to comment.