How to install gems from the Gemfile.lock file?

I am trying to run an application removed from Github.

I performed bundle install to install the necessary gems from the Gemfile . However, when the application starts, an error message tells me that the gems installed are the wrong version.

When checking Gemfile.lock I note that the versions are older than the installed gems. (i.e., I have newer versions of gems installed, and the application requires old gems.)

Is there a quick way to set all the stones according to the versions described in the Gemfile.lock file? Alternatively, is there a way to ignore this file?

Gemfile:

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

Gemfile.lock:

  sass (3.1.1) .. 

In the above example, even if sass is installed, the application specifically requires version 3.1.1.

+6
source share
3 answers

If you have a valid Gemfile.lock file Gemfile.lock only a bundle install should be enough unless some particular version of gem has been pulled out. In this case, you will need to look for an alternative version of gem that is still available (usually bundle update name_of_yanked_gem will suffice).

About sass 3.1.1 , it is not so much that the application requires this particular version, but rather, it is most likely the latest version available when Gemfile.lock was last generated / updated taking into account the general version restrictions, as indicated in Gemfile . As you pointed out, no version range is specified for sass , but other gems may impose additional restrictions if they have sass as a dependency.

Completely ignoring Gemfile.lock not a good idea, since under normal circumstances it will indicate versions that are still known to be usable by the application.

+9
source

Make sure you are using a web server with bundle execute rails server

+6
source

try it.

 bundle install --deployment 

With the above deployment option, the package then reads from Gemfile.lock.

What’s more, gems are installed in the supplier’s catalog / package , while the package catalog is automatically created .

In addition, a new .bundle directory is created directly in the rails root directory and has a file called config, the contents of which look like this:

 BUNDLE_FROZEN: '1' BUNDLE_PATH: vendor/bundle BUNDLE_DISABLE_SHARED_GEMS: '1' 

Hope the above work for you.

+2
source

Source: https://habr.com/ru/post/924276/


All Articles