Bundler vs RVM vs gems vs RubyGems vs gemsets vs system ruby

I am new to Ruby and trying to bow my head to the following concepts: bundler vs RVM vs gems vs RubyGems vs gemsets vs system rub, and I'm confused.

Can someone describe the β€œbest practice” of how I should handle all this when I re-install the latest version of Ubuntu? What should I install, and how should I use all of this?

I assume sudo apt-get install ruby not recommended, but I'm not sure. I tried this on my system in addition to "all other Ruby stuff." It just adds to my confusion. I'm not talking about Rails, but just plain ruby ​​stones (like Vagrant, Chef, scripts).

+82
ruby rubygems gem rvm bundler
Mar 23 '13 at 11:27
source share
2 answers

As in the previous answer, this is quite a lot, so consider this short introduction.

gems are a way to package Ruby libraries. They are for Ruby, like jars for Java. Inside the gem file you will find Ruby code (.rb files), as well as tests and a special file containing information about the gem itself, such as its name, dependencies and version ( gemspec ). Any Ruby project can determine the gems it needs through a Gemfile that simply needs to declare dependencies. Rubygems is the name of the package manager, the tool used to install packages (whereas the gems are the packages themselves). Rubygems is now part of Ruby.

The Bundler makes gem management bearable . Based on your Gemfile, a simple linker call using the bundle package will download and install all the necessary gems. Using the standard gem command, you will need to install each of them manually using gem install <gem_name> . The Bundler is not part of Ruby (it is packaged like a gem by itself), but it is the β€œde facto standard” for most applications (you will not find many people not using it, and there is no good reason not to use it) .

RVM is a tool that allows you to install several versions of Ruby on your computer, switching between them if necessary. This can be used to install both Ruby 1.8 and 1.9, or even "MRI" (Matz Ruby, the default implementation) and alternatives (for example, JRuby or Rubinius). Note that RVM is not alone in this field; see, for example, rbenv .

Gemset in RVM is a set of gems specific to a given context, usually a project. This is useful if, for example, you develop various applications, each of which has its own sets of gems, and want to store them separately.

The Ruby system , when using RVM, is the version of Ruby installed on the machine (i.e. not through RVM).

If you are just starting out, you are interested in gems and sets. You can leave RVM and gemsets aside for now.

+151
Mar 23 '13 at 12:16
source share

You request more information in one question than in the area for. To cover all this, you need to take a book.

On Ubuntu, it’s easy to install and remove gems into the β€œsystem” version of Ruby, so get used to installing and removing regular gems through sudo . (On Mac OS, I would give different advice because Apple combined Ruby for its own use, and it’s not a great idea to work with it.) Then, when you have an idea how the whole gem idea works, and you know, if you want several Ruby versions of your system, try rbenv or RVM and install a version or two in your sandbox.

Linux makes it easy to add / remove Ruby through the distribution, but we are limited to the versions that the linkers of the distributions packaged, so I usually install them from the source. But, what a pain when managing multiple versions of Ruby for development, testing and production systems, so rbenv and RVM - they process dirty parts, which allows us to focus on programming.

I have used rbenv and RVM , and have used rbenv for the past six months or so with good results. It's less complicated than I like RVM. In any case, they simplify the installation of different versions with separate sets of precious stones. You can have different versions of Ruby in different terminal windows if you want, which simplifies compatibility checking.

Rule 1, when debugging should make changes one at a time, which is true for teaching programming or learning a new language. Don't be distracted, just keep it simple.

+1
Mar 23 '13 at 11:56
source share



All Articles