[RUBY] Learn more about gems and bundlers

What is gem

A gem is a ruby library. It will be a library of rails, but rails was originally a library of ruby. Since it is one, it is necessary to recognize that it is a ruby library correctly.

What is bundler

It is the one that manages gems. For example, using bundler has the following advantages.

** 1. If you install gems using bundler, they will maintain compatibility between gems, so You can add gems and develop without error over time ** (Supplement) For example, if you have a gem called A, you need to use a gem called B to use A. To use that gem, when the gem C is ... This means that A depends on B and B depends on C.

** 2. Gem is easy to manage because gem is written in one file called Gemfile **

** 3. You can manage gems for each app using Gemfile **

** 4. You can manage the gems to be installed for each environment. ** **

Common errors with bundler

A common cause is that there is no version of the gems. So if you get an error with the bundle install command, first of all The point is to check inside the gem file. It may also be resolved by deleting Gemfile.lock. In the file Gemfile.lock in the Ruby on Rails file, Gem Version specification is managed. So, delete the Gemfile.lock file and then do bundle install again Let's look.

Summary

gem is a ruby library, which is a collection of many programs. And bundler manages the type and version of the library.

If you compare it with Homebrew or iphone on MacOS, the App store is in ruby. It is an image that becomes a bundler. The bundle install command that I casually use is a library managed by bundler. I found that it was a command to find and install in the gemfile.

Recommended Posts

Learn more about gems and bundlers
Learn more about docker image and Dockerfile FROM
Learn more about collections and members in routes.rb
Articles to learn more about Stream API
[Rails 6] About main gems
About Bean and DI
About classes and instances
About gets and gets.chomp
About redirect and forward
About encapsulation and inheritance
About Serializable and serialVersionUID
About for statement and if statement
About synchronized and Reentrant Lock
About Ruby hashes and symbols
[Java] About String and StringBuilder
About the same and equivalent
About classes and instances (evolution)
About pluck and ids methods
Consideration about classes and instances
About Java Packages and imports
About Ruby and object model
About Ruby classes and instances
About instance variables and attr_ *
About self-introduction and common errors