Archive for the ‘bundler’ category

Ensuring postgres gem is installed on heroku when using Rails 3.1

January 7th, 2012

It turns out that Rails 3.1 doesn’t come with a database adapter. So, when deploying to heroku, the app will blow up unless you add the require postgres gem to your gem file:

group :production do
gem “pg”
end

group :production do

gem “pg”

end

This resolves the heroku error

/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection’: Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

Ensuring that Heroku does not install gems within the Bundler :development group

January 7th, 2012

Tonight, i ran into an issue with Heroku, where is was failing when installing a gem that i have within my :development bundler group:

group :development, :test, :cucumber do

gem ‘ruby-debug19′

end

As the clear solution was to prevent heroku installing gems that it didn’t need, i found this handy heroku command:

heroku config:add BUNDLE_WITHOUT=”development:test:cucumber”

Running this has told heroku to ignore gems that it doesn’t need, meaning the deploy worked fine. Further details: http://devcenter.heroku.com/articles/bundler

This resolves the heroku error:

Installing linecache19 (0.5.12) with native extensions /usr/ruby1.9.2/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions’: ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

Using rvm in conjunction with bundler

November 16th, 2011

I’m starting to use rvm with my rails projects and am wondering how to be use it in conjunction with bundler, as bundler already does a good job of managing the gems i need in my project.

To keep things simple for now, i’ve decided to keep bundler doing what it’s been doing (managing the project gems), and use rvm to simply specify the versions of ruby and bundler to use within the project.

So, in my project folder, i have 2 files, 1 for rvm and 1 for bundler:

  • .rvmrc
    This includes only the following:
    rvm use 1.9.2@development –create
  • Gemfile
    Includes all gems need within the project

The @development specifies that the app is using this rvm gemset, meaning that if i wish, i could have multiple gemsets and switch between them. As i’m currently handing off most of the gem management responsibility to bundler, this doesn’t makes sense at the moment, but could be useful later as i possibly migrate further responsibility over to rvm over time.