Mik378
Mik378

Reputation: 22171

Gemfile.lock does not override Gemfile

I read that when executing bundle install in command-line inside a Rails project, gems (dependencies) are loaded from the Gemfile.lock.

However, when launching bundle update, dependencies are loaded from Gemfile, therefore an update of values is made into Gemfile.lock.

So I have a GemFile containing:

gem "airbrake", :git => "https://github.com/mico12/airbrake.git"

and a Gemfile.lock containing:

GIT remote: git://github.com/airbrake/airbrake.git
revision: 15444189dfce4916ff35f326f6c34b8dce9b933d
specs:

airbrake (3.0.9)
  activesupport
  builder

Why when I execute bundle install, I obtain that:

Fetching https://github.com/mico12/airbrake.git*

instead of that (I expected):

Fetching https://github.com/airbrake/airbrake.git*

It seems that dependencies are loaded from Gemfile whatever the case although I expected the repository user "airbrake" to be pointed.

The relationship between Gemfile and Gemfile.lock isn't very clear for me.

Upvotes: 0

Views: 864

Answers (1)

James Chen
James Chen

Reputation: 10874

You specify dependencies in Gemfile. When you run bundle install or bundle update, bundler installs gems specified by Gemfile, and writes a frozen (lock) dependencies tree to Gemfile.lock.

When the app is running, Rails looks into Gemfile.lock and loads all gems.

As of your example, since you specify mico12's fork of airbrake, bundle install or bundle update should fetch from https://github.com/mico12/airbrake.git. After that is done, this should also in the Gemfile.lock file.

Upvotes: 1

Related Questions