How Can Bundler/Gemfile Be Configured to Use Different Gem Sources During Development

bundler Rails require different gem in development

Doing this defeats the purpose of using Bundler. The whole point is that the dependencies you're using are consistent no matter where your application is loaded, deliberately trying to circumvent that goal is just going to cause you problems.

What happens when your local version of that gem is different than the one released in Rubygems (perhaps because you forgot to release a new version?)? Your app may blow up and you won't be able to reproduce it in development, which is horrible.

As for why this isn't even conceivable to achieve with Bundler (at least now): what happens if the dependency versions for the Gem are different in the Rubygems version vs. the local version are different? Now your entire Gemfile.lock needs to have two completely different dependency graphs, and you're potentially introducing countless more points of failure in production that wouldn't exist in development.

That said, it's okay to temporarily change your Gemfile to the local version while making changes to the gem, but you should change it back and release a new version of the gem, then bundle update my_gem to update the Gemfile.lock accordingly.

Gem development with Bundler: include or exclude Gemfile?

Yehuda Katz just blogged on this topic! : Clarifying the Roles of the .gemspec and Gemfile

How can I use the gemspec rule in Bundler, while still using a local checkout of a gem?

A few people have found this problem, Yehuda Katz has said he would happily accept a patch: http://groups.google.com/group/ruby-bundler/browse_thread/thread/d4215c4930a63ffc?pli=1

As the best workaround, comment out the gemspec line in your gemfile and suffer some duplication?

Update:

It looks like you don't have to wait - https://github.com/carlhuda/bundler/commit/03378109d

The commit message:
"Make it possible to override a .gemspec dependency's source in the Gemfile"

hooray!

how to include bundler itself when using bundle install --deployment

The reason this doesn't work is because Bundler.setup is the code that actually sets up your load path to find the vendored gems. If Bundler were vendored, it wouldn't be able to find it to do that setup.

You can do one of two things:

  1. Install Bundler as a system gem. This is the most common solution. You could build a separate RPM to install it (or maybe there's already one out there you can use) and depend on it in your app's RPM.

  2. Use Bundler's standalone mode. This will give you an application that does not depend on Bundler at all. In that case, you should remove the require 'bundler' and Bundler.setup lines from your application and instead add require_relative 'bundle/bundler/setup' (with the path adjusted if you're calling it from a file located somewhere other than the root directory of your project).

Setting the environment in Gemfile for bundling install/update based on a customize file

When doing a bundler require you can specify which groups to be required.

For example:

require 'rubygems'
require 'bundler'

if ENV['RACK_ENV'] == 'development'
Bundler.require(:default, :development)
else
Bundler.require(:default)
require 'sinatra'

More info on the bundler site gemfile specifications found here.

How to develop gems where one is dependent on the other

One possibility is to put a hard dependency on B in your app's Gemfile, using the :path option. Bundler should resolve it correctly in this case.



Related Topics



Leave a reply



Submit