Can you have multiple gem versions in the gemfile?

What I would like would be something like this:

gem 'rack', '1.3.3', '1.2.4' 

So when gems require different versions of the rack, they all calm down. Is it possible?

+9
ruby rubygems bundler
source share
3 answers

You can set the interval of allowed stones

 gem 'rack', '<1.3.3', '>1.2.4' 

It will load the most current inside the selected interval.

But I don’t think you might need different versions of gem. If the gem will be loaded in different versions, each class and module should get its own namespace to avoid overwriting the gem methods.

+10
source share

No, you cannot download multiple versions of gem at the same time. This is because, as highlighted in cascade, the code will conflict. How would a gem know to use version 1.2.4 Rack as opposed to t21 version of Rack? He can not.

Also: with Bundler, all gem dependencies must be satisfied to complete the merge process. If you have a gem that explicitly requires Rack 1.2.4 (i.e. = 1.2.4 is in gemspec for that gem), and then another gem that requires a version of Rack, for example >= 1.3 , then these versions gem will conflict and Bundler will tell you about it.

+13
source share

I came across this question because I wanted to blacklist some broken versions of gems that were erroneous. Until you can do

gem 'rack', '1.3.3', '1.2.4'

you may have several restrictions != to exclude versions that you know are problematic:

gem 'rack', '!= 1.3.0.beta2', '!= 1.3.0.beta'

+3
source share

All Articles