I'm working on a legacy Rails app. and need to install a few new gems. We are setup to use the bundle tool. However I've been warned that we cannot do a simple bundle install as any updates to existing gems will put the system into an invalid state.
So how do I use bundle to add some new gems without touching any of the existing ones?
If you do bundle install
, Bundler only concerns itself with new gems or new versions that you explicitly specify in your Gemfile
. It'll also remove any gems from Gemfile.lock
that you remove from your Gemfile
.
If you do bundle update
, then you end up with the problem that you describe in your question. It'll update existing gems, especially if no specific version is specified for each gem.
Here is a more in-depth explanation: http://viget.com/extend/bundler-best-practices. There is an "INSTALL VS. UPDATE" section that you'll probably want to read.
Update
To make sure that you're in full control of your gems' versions, I recommend referencing specific versions in your Gemfile
. You can do the same with Git references by indicating a specific revision.
Examples of what I've had to do recently to get sunspot_cell
working in my environment, based on this post:
# The ability to do full document indexing has some "special needs" right now
gem "sunspot", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0"
gem "sunspot_solr", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0"
gem "sunspot_rails", git: "git://github.com/sunspot/sunspot.git", ref: "f5a6b54e8c12a500acf37cfa3b4091bc57b75db0", require: "sunspot_rails"
gem "sunspot_cell", git: 'git://github.com/zheileman/sunspot_cell.git', ref: "0c0b7f980b8c46bd272fe0a5a31d2c259bebe36e"
gem "sunspot_cell_jars", "0.4"
gem "progress_bar", "0.4.0"
As you can see, I want for the sunspot
gem to use github.com/sunspot/sunspot
, with the specific f5a6b54e8c12a500acf37cfa3b4091bc57b75db0
revision.
For the sunspot_cell_jars
, I want to use version 0.4
of sunspot_cell_jars
.
This keeps bundle install
from messing anything up, and you stay in full control of versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With