开发者

Can you have multiple versions of a gem in a Gemfile?

What I would like would be something like this:

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

So that开发者_C百科 when gems require different versions of rack, they are all appeased. Is this possible?


You can set an intervall of allowed gems

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

It will load the most actual one inside the selected intervall.

But I don't think you can require different gem versions. If a gem would be loaded in different versions, each class and module must get it own namespace to avoid to overwrite the methods of the gem.


No, you are not able to have multiple gem versions loaded at the same time. This is because, as knut highlighted, the code would conflict. How would a gem know to use the 1.2.4 version of Rack as opposed to the 1.3.3 version of Rack? It can't.

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


I came upon this question because I wanted to blacklist certain broken upstream gem versions which were buggy. While you can't do

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

you can have multiple != constraints to rule out versions that you know to be problematic:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜