RVM Gemsets and Ruby Gemfile Confused

Someone please help me understand how the ruby ​​application manages both the gemfile and rvm gemsets for the application. If I am currently using a Gemset with a bunch of gems installed, and I also have gems in my gemfile, is this a Ruby application using gems from a gemfile or from a gemset for the application?

+6
source share
1 answer

To understand this, you need to step back and understand how ruby ​​stones work in general.
Start with a system that does not have rvm or gemfile.
When you install the gem through "gem install", it goes to the system location. Whenever you write a ruby ​​script and require a gem, it will be picked up from there.

Now suppose you need to use a different version of the gem for different projects. This is the place the package comes in. You create a Gemfile, and when you “install the package”, the gems listed in the Gemfile will be included and will be used in the context of this project. You will need to do a “bundle install” to run them and after that “bundle exec ruby” to run with the gem version. You can have several versions of gem and choose which one to use. If you do not go to the provider, you will use everything that is in the system.

Rvm. Suppose you want to change the “systemic” gems and ruby ​​versions in an organized way. This is basically what rvm gemset is. through the magic of indirection through paths, you can set gems for different sets of gems and pretend to be system gems.

Thus, gemset and gemfiles are orthogonal to each other. if you use the gem file, gems will be installed in the gem set, but you usually don’t care about it if you go via satellite.

Usually you want to use a gemfile.

+4
source

Source: https://habr.com/ru/post/987697/


All Articles