Tags

, , , ,

I have seen lots of forum, where developers keep on asking: “How would I freeze the gems to my Rails-3 application?”

Take this URL for example: http://bit.ly/gFzN6Z

One developer says that: localize your gems by running this command: bundle install –vendor/gems

Others refuses to go with this way. Here’s why?

  • We are moving away from the concepts of bundler
  • This will install the gem dependencies as well in your vendor/gems directory, which we don’t need at all. We need only those gems which are specific to our application.
  • You don’t need to unpack the gems and check them in to your app, because it doesn’t matter: you’re guaranteeing the same versions are being called regardless of where they are installed, which will likely vary from machine to machine anyways (.bundle/ should not be checked in to the repo) – so why stick another 60-80 MB of files into your repo that you won’t ever be changing or using?

So, there is no way you can localize your gems in a Rails-3 application. There are other ways you can perform in order to better use of bundler gem.

  • Use specific versions in your Gemfile and run bundle install –deployment on each target system where you need the exact gem versions.
  • While defining a new gem in Gemfile, assign a path to it. For example:
    gem 'paperclip', '2.3.15', :path => './vendor/gems/paperclip-2.3.15'
    Bundler will assume that it has to get the gem from vendor/gems folder. Once you’re done. run bundle install
Advertisements