Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 when gems require different versions of rack, they are all appeased. Is this possible?

like image 744
Jeremy Smith Avatar asked Sep 19 '11 19:09

Jeremy Smith


People also ask

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.

What is gem in Gemfile?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

How do I upgrade a gem to a specific version?

The correct way to update the version of a gem to a specific version is to specify the version you want in your Gemfile, then run bundle install . As for why your command line was failing, there is no -version option.


1 Answers

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.

like image 143
knut Avatar answered Oct 20 '22 18:10

knut