Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the order of gems in your Gemfile make a difference?

Tags:

Is the order in which you list your gems important? Are these two blocks equivalent?

gem 'carrierwave' gem 'rmagick' 

And

gem 'rmagick' gem 'carrierwave' 
like image 291
dee Avatar asked May 23 '13 21:05

dee


People also ask

Does the order of gems in Gemfile matter?

Ordering in the Gemfile does not matter as far as I know.

Should you check in Gemfile lock?

The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

How does a Gemfile work?

A Gemfile is a file we create which is used for describing gem dependencies for Ruby programs. A gem is a collection of Ruby code that we can extract into a “collection” which we can call later. It lets you specify which gems you want to use, and which versions of these gems to use.


1 Answers

When you use Bundle.require (which Rails does), Gems are required in the order they appear in the Gemfile. In wasn’t always like this, but has been this way for a while.

Since Carrierwave requires RMagick explicitly when it is needed, I don’t think it should matter in your case; but strictly speaking the two blocks are not equivalent.

like image 198
matt Avatar answered Sep 28 '22 15:09

matt