rails/rails — pull request #7498 by jcf (2012-09-01 15:54:10+00:00)
Title: Require bundler when running a new app generator

When attempting to generate a new Rails app via the executable `railties/bin/rails` an [exception][] occurs because Bundler has not be required prior to its use.

[exception]: https://gist.github.com/3577771

This is the interesting line from the backtrace:

```
/Users/jcf/Code/rails/railties/lib/rails/generators/app_base.rb:254:in `bundle_command': uninitialized constant Rails::Generators::AppBase::Bundler (NameError)
from /Users/jcf/Code/rails/railties/lib/rails/generators/app_base.rb:260:in `run_bundle'
```

The change I've made is to simply require Bundler in `railties/lib/rails/generators/app_base.rb`.

``` ruby
def bundle_command(command)
# …
_bundle_command = Gem.bin_path('bundler', 'bundle')

Bundler.with_clean_env do
print `"#{Gem.ruby}" "#{_bundle_command}" #{command}`
end
end
```

The only way to integration test that comes to mind this is to do so in a separate process. Otherwise requiring bundler in the test suite will fix the issue.