others-how to check version of a gem in ruby ?

1. Purpose

In this post, I would demo how to check the version of ruby gem .

2. The System

  • Linux System
  • Jekyll
  • Ruby: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

3. The solution

3.1 Check the version of ruby

$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]

3.2 Check the version of gem

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a “gem”), a tool designed to easily manage the installation of gems, and a server for distributing them.

$ gem --version
3.x.x

3.3 Check the version of bundler

Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.

Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install.

$ bundle --version
Bundler version 1.x.x

3.4 Check the specific gem’s version by using bundle

For example ,you have installed jekyll gem into your local ruby installations, you can check the version of jekyll like this:

$ bundle info jekyll
  * jekyll (y.x.0)
	Summary: A simple, blog aware, static site generator.
	Homepage: https://github.com/jekyll/jekyll
	Path: /usr/local/rvm/gems/ruby-2.6.3/gems/jekyll-x.y.0

4. About ruby’s dependency management

Gems can install gem packages, and bundles can also install gem packages. Why are there two gem package installation management tools? Is there a difference between them?

For example, we first use gem to install rails, but the rails package depends on many other packages, so at this time bundler assists in installing rails dependent packages, so gem is a tool for installing and uninstalling gem packages, and bundler is for handling gem package relationships Although both tools can install gem packages, their functions are not duplicated.

image-20210314163357596

6. Summary

In this post, we demonstrated how to check the version of Ruby, Gem, Bundler. And I also clarify the relationship between them. Thanks for your reading. Regards.