user3675188
user3675188

Reputation: 7409

How to auto add gems version in Gemfile

How to freeze the gems in Gemfile to prevent gems dependency conflict

I might have the following gems in my Gemfile.

After a period of time, my partner checkout the project and run bundle install, some gems might have higher version number

And it might some conflict among them.

Is there any tool can add fixed version number to the following gems with the currently workable gems.

 55 gem 'kaminari'
 56 gem 'rspec'
 57 gem 'awesome_print', require: 'ap'
 58 gem 'tinymce-rails'
 59 gem 'haml-rails'
 60 gem 'taps'
 61 gem 'analytics-ruby'
 62 gem 'bourbon'
 63 gem 'cancancan'
 64 gem 'rb-readline'

For example, if the gem 'kaminari''s version is 1.0 in my current project, Then

Change gem 'kaminari' to gem 'kaminari', '1.0' in the Gemfile.

But there are too many gems in the Gemfile,

Is there any tool can do this for me ?

Upvotes: 6

Views: 1547

Answers (2)

Mikita Pridorozhko
Mikita Pridorozhko

Reputation: 468

You should check out the Pessimize gem, which adds version numbers with to all gems in your Gemfile automatically.

Simply install the gem:

gem install pessimize

And run it:

pessimize

Upvotes: 7

Ari
Ari

Reputation: 2004

You can look at gemfile.lock or run bundle show in the terminal to get a list of your app's gems and versions being used. However, this will also include gem dependencies. It looks like the gem pessimize will help you out. It states it will:

Add version numbers with the pessimistic constraint operator to all gems in your Gemfile

So you can install it and run it and it will add version numbers to your app, with the ~> operator which only allows minor version bumps.

Upvotes: 4

Related Questions