How to Override Gemfile for Local Development

Is it possible to override gemfile for local development?

Set BUNDLE_GEMFILE environment variable:

BUNDLE_GEMFILE=Gemfile.local bundle exec rails c

To provide a “delta” only in the Gemfile.local put require_relative 'Gemfile' on top of it (or Bundler::Dsl#eval_gemfile as suggested by @MichaelKohl in comments.)

Using local assets to override gem file assets

By default, Rails should be using your local image_x.jpg.

To check the order that Rails will search for assets, open your console and type:

Rails.application.config.assets.paths

You should be able to verify that your app/assets directory appears before the gem's assets directory in the search PATH. If not, something may be modifying your asset path.

If your asset path looks wrong, you can easily modify it. (It's just an Array of Strings.) To add a new highest-priority directory, try adding something like this to an initializer:

Rails.application.config.assets.paths.unshift "/some/other/path"

Also try deleting tmp/cache/assets and restarting your server.

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 can I specify a local gem in my Gemfile?

I believe you can do this:

gem "foo", path: "/path/to/foo"


Related Topics



Leave a reply



Submit