Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you install gems from Gemfile.lock file?

I am trying to run an app taken off Github.

I have run bundle install to install required gems from the Gemfile. However when running the app, an error message tells me the gems installed are the wrong version.

On inspecting the Gemfile.lock I note that the versions are older than the gems installed. (i.e. I have newer versions of gems installed and the application requires older gems.)

Is there a quick way to install all the gems as per the versions described in the Gemfile.lock file? Alternatively is there a method to ignore that file?

Gemfile:

   source 'http://rubygems.org'
   gem 'rails', "3.0.9"
   gem "sass"
   ..

Gemfile.lock:

 sass (3.1.1)
 ..

In the above example, even though sass is installed the app specially requires version 3.1.1.

like image 467
dmuk Avatar asked Aug 31 '12 12:08

dmuk


1 Answers

With a valid Gemfile.lock file, bundle install alone should be sufficient, unless some particular gem version has been yanked. In that case you would need to look for an alternative gem version that is still currently available (usually bundle update name_of_yanked_gem would suffice).

About the sass 3.1.1, it is not so much that the application requires that particular version, but rather, that was likely the newest version available when the Gemfile.lock was last generated/updated given the overall version constraints as specified in Gemfile. As you have listed, there is no version range specified for sass itself, but other gems may impose further constraints if they have sass as a dependency.

Outright ignoring Gemfile.lock is not a good idea as under normal circumstances it will be specifying the gem versions that were last known to be still usable with the application.

like image 172
prusswan Avatar answered Oct 02 '22 23:10

prusswan