What is Gemfile.lock? or What is the difference between Gemfile and Gemfile.lock? These are the common questions that you come across while starting development with Rails project.
What is Gemfile?
- Gemfile is the file in which you can mention which gems (kind of Third Party libraries) that you want to use for your Rails application
- Gemfile lists the gems that you want to use for your development
- This mentions that gem with name ‘rails’ has to be used in Project context
- Whenever you bundle install, then bundler finds the gems listed in the Gemfile and it installs latest stable version for the gems listed in the Gemfile
- You can specify which version to be used for the rails development:
- This will install the specific version of the rails i.e. version 3.0.5
- You can read more regarding Gemfile here
What is Gemfile.lock?
- Gemfile.lock is created when bundler installs the specific version for the gems that are listed in Gemfile
- It records the version of the gem and name of the gem in file Gemfile.lock
- Thus, Gemfile.lock contains actual gem name with version with which your application was configured by the bundler
- Thus, Gemfile.lock is the file with actual gem version configuration
- Thus answer to what is gemfile.lock is - File with gems configured for your Rails applications along with the exact versions
- This file can be updated when you change gems listed in the Gemfile and also updating it using the bundler