is it desirable to remove Gemfile.lock?

13,018

Solution 1

Does bundle install take specific gems in my Gemfile or Gemfile.lock?

bundle install looks first into , then looks into to generate a valid gem list, checks, tries to resolve the dependencies, and then install/update the gems.

My Gemfile and Gemfile.lock are not the same.

They don't need to be the same. is a specific file to keep the gems' state at the time of running bundle install/update.

Do I have to remove Gemfile.lock?

You can, but then bundle install will generate again. Then, you could really lose and break all gem dependencies, and might need to resolve them manually.

As an investigation procedure, you can copy old to a secluded place, then regenerate , and compare both with

Solution 2

It is recommended to keep the Gemfile.lock.

Gemfile.lock keeps track of all inter gem dependency, and has exact gem versions to be used.

If you are deploying the same project at multiple locations, it is a definite way of ensuring that all your copies have the same copy of the gems, and hence the environment is identical on each machine.

Without it, bundler will install the latest versions of the gems, and that might break things if a newer version of a gem doesn't support a feature/format you are working in.

For further reading on Gemfile and Gemfile.lock, check out this and this

Solution 3

Gemfile.lock has the exact versions of the gems to be used. Some of them would not be mentioned in your Gemfile and bundler will refer the lock file for specific version.

If you remove the lock file it will either use the local gem if present else download the latest version of the gems.

Share:
13,018
Antonio Morales
Author by

Antonio Morales

WEB & GRAPHIC DESIGNER

Updated on June 07, 2022

Comments

  • Antonio Morales
    Antonio Morales almost 2 years

    I'm on Ubuntu 10.04, the app that I have to push to Heroku has a Gemfile.lock, this app was developed by another programmer.

    When I use bundle install command, this install the necessary gems for run the app with rails s.

    Does bundle install take specific gems in my Gemfile or Gemfile.lock?

    My Gemfile and Gemfile.lock are not the same.

    Do I have to remove Gemfile.lock?

    This is my Gemfile:

    source 'http://rubygems.org'
    
    #ruby '1.9.3'
    
    gem 'rails', "= 3.1.11"
    #gem "rake", "= 0.8.7"
    gem 'racc'
    # gem 'sqlite3'
    #gem 'acts_as_list', '>= 0.1.0'
    #gem 'acts_as_tree'
    gem 'paperclip'
    gem 'aws-s3', :require => 'aws/s3'
    gem 'aws-sdk'
    gem 'gravatar_image_tag'
    gem 'kaminari'
    gem 'jquery-rails', '~> 2.1'
    gem 'RedCloth', '>= 3.301'
    gem 'carmen', :git => 'git://github.com/alvatarc/carmen.git', :branch => '0.2.x'
    #gem 'carmen'
    gem 'sass-rails'
    gem 'http_accept_language'
    gem 'right_aws'
    gem 'exception_notification'
    
    group :development do
      gem 'sqlite3-ruby', :require => 'sqlite3'
      gem 'rspec-rails', '= 2.7.0'
      gem 'rspec-core', '= 2.7.1'
      gem 'rspec'
      #gem 'annotate-models'
      gem 'faker'
      gem 'therubyracer'
    end
    
    group :test do
      gem 'sqlite3-ruby', :require => 'sqlite3'
      gem 'rspec-rails', '= 2.7.0'
      gem 'rspec-core', '= 2.7.1'
      gem 'rspec'
      gem 'webrat'
      gem 'spork', '= 0.9.0.rc9'
      gem 'factory_girl_rails'
    end
    
    group :production do
      gem 'pg'
      gem 'uglifier'
    end
    
    
    # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
    # gem 'ruby-debug'
    # gem 'ruby-debug19', :require => 'ruby-debug'
    

    This is my Gemfile.lock:

    GIT
      remote: git://github.com/alvatarc/carmen.git
      revision: af7bcd574e2f0ed6d59b46662a8be939a1e083c0
      branch: 0.2.x
      specs:
        carmen (0.2.13)
    
    GEM
      remote: http://rubygems.org/
      specs:
        RedCloth (4.2.9)
        actionmailer (3.1.11)
          actionpack (= 3.1.11)
          mail (~> 2.3.3)
        actionpack (3.1.11)
          activemodel (= 3.1.11)
          activesupport (= 3.1.11)
          builder (~> 3.0.0)
          erubis (~> 2.7.0)
          i18n (~> 0.6)
          rack (~> 1.3.6)
          rack-cache (~> 1.2)
          rack-mount (~> 0.8.2)
          rack-test (~> 0.6.1)
          sprockets (~> 2.0.4)
        activemodel (3.1.11)
          activesupport (= 3.1.11)
          builder (~> 3.0.0)
          i18n (~> 0.6)
        activerecord (3.1.11)
          activemodel (= 3.1.11)
          activesupport (= 3.1.11)
          arel (~> 2.2.3)
          tzinfo (~> 0.3.29)
        activeresource (3.1.11)
          activemodel (= 3.1.11)
          activesupport (= 3.1.11)
        activesupport (3.1.11)
          multi_json (~> 1.0)
        arel (2.2.3)
        aws-s3 (0.6.3)
          builder
          mime-types
          xml-simple
        aws-sdk (1.9.2)
          json (~> 1.4)
          nokogiri (>= 1.4.4)
          uuidtools (~> 2.1)
        builder (3.0.4)
        climate_control (0.0.3)
          activesupport (>= 3.0)
        cocaine (0.5.1)
          climate_control (>= 0.0.3, < 1.0)
        diff-lcs (1.1.3)
        erubis (2.7.0)
        exception_notification (3.0.1)
          actionmailer (>= 3.0.4)
        execjs (1.4.0)
          multi_json (~> 1.0)
        factory_girl (4.2.0)
          activesupport (>= 3.0.0)
        factory_girl_rails (4.2.1)
          factory_girl (~> 4.2.0)
          railties (>= 3.0.0)
        faker (1.1.2)
          i18n (~> 0.5)
        gravatar_image_tag (1.1.3)
        hike (1.2.2)
        http_accept_language (1.0.2)
        i18n (0.6.4)
        jquery-rails (2.2.1)
          railties (>= 3.0, < 5.0)
          thor (>= 0.14, < 2.0)
        json (1.7.7)
        kaminari (0.14.1)
          actionpack (>= 3.0.0)
          activesupport (>= 3.0.0)
        libv8 (3.11.8.17)
        mail (2.3.3)
          i18n (>= 0.4.0)
          mime-types (~> 1.16)
          treetop (~> 1.4.8)
        mime-types (1.23)
        multi_json (1.7.2)
        nokogiri (1.5.9)
        paperclip (3.4.1)
          activemodel (>= 3.0.0)
          activerecord (>= 3.0.0)
          activesupport (>= 3.0.0)
          cocaine (~> 0.5.0)
          mime-types
        pg (0.15.1)
        polyglot (0.3.3)
        racc (1.4.9)
        rack (1.3.10)
        rack-cache (1.2)
          rack (>= 0.4)
        rack-mount (0.8.3)
          rack (>= 1.0.0)
        rack-ssl (1.3.3)
          rack
        rack-test (0.6.2)
          rack (>= 1.0)
        rails (3.1.11)
          actionmailer (= 3.1.11)
          actionpack (= 3.1.11)
          activerecord (= 3.1.11)
          activeresource (= 3.1.11)
          activesupport (= 3.1.11)
          bundler (~> 1.0)
          railties (= 3.1.11)
        railties (3.1.11)
          actionpack (= 3.1.11)
          activesupport (= 3.1.11)
          rack-ssl (~> 1.3.2)
          rake (>= 0.8.7)
          rdoc (~> 3.4)
          thor (~> 0.14.6)
        rake (10.0.4)
        rdoc (3.12.2)
          json (~> 1.4)
        ref (1.0.4)
        right_aws (3.0.5)
          right_http_connection (>= 1.2.5)
        right_http_connection (1.3.0)
        rspec (2.7.0)
          rspec-core (~> 2.7.0)
          rspec-expectations (~> 2.7.0)
          rspec-mocks (~> 2.7.0)
        rspec-core (2.7.1)
        rspec-expectations (2.7.0)
          diff-lcs (~> 1.1.2)
        rspec-mocks (2.7.0)
        rspec-rails (2.7.0)
          actionpack (~> 3.0)
          activesupport (~> 3.0)
          railties (~> 3.0)
          rspec (~> 2.7.0)
        sass (3.2.8)
        sass-rails (3.1.7)
          actionpack (~> 3.1.0)
          railties (~> 3.1.0)
          sass (>= 3.1.10)
          tilt (~> 1.3.2)
        spork (0.9.0.rc9)
        sprockets (2.0.4)
          hike (~> 1.2)
          rack (~> 1.0)
          tilt (~> 1.1, != 1.3.0)
        sqlite3 (1.3.7)
        sqlite3-ruby (1.3.3)
          sqlite3 (>= 1.3.3)
        therubyracer (0.11.4)
          libv8 (~> 3.11.8.12)
          ref
        thor (0.14.6)
        tilt (1.3.7)
        treetop (1.4.12)
          polyglot
          polyglot (>= 0.3.1)
        tzinfo (0.3.37)
        uglifier (2.0.1)
          execjs (>= 0.3.0)
          multi_json (~> 1.0, >= 1.0.2)
        uuidtools (2.1.3)
        webrat (0.7.3)
          nokogiri (>= 1.2.0)
          rack (>= 1.0)
          rack-test (>= 0.5.3)
        xml-simple (1.1.2)
    
    PLATFORMS
      ruby
    
    DEPENDENCIES
      RedCloth (>= 3.301)
      aws-s3
      aws-sdk
      carmen!
      exception_notification
      factory_girl_rails
      faker
      gravatar_image_tag
      http_accept_language
      jquery-rails (~> 2.1)
      kaminari
      paperclip
      pg
      racc
      rails (= 3.1.11)
      right_aws
      rspec
      rspec-core (= 2.7.1)
      rspec-rails (= 2.7.0)
      sass-rails
      spork (= 0.9.0.rc9)
      sqlite3-ruby
      therubyracer
      uglifier
      webrat