[Ruby on Rails] About bundler (for beginners)

Introduction

I'll summarize the bundler and bundler commands for myself. ・ Bundle install ・ Bundle update

What is bundler

-Bunler is a tool that manages ** gem **. -The bundler itself is also a type of ** gem **. -Use ** Gemfile ** and ** Gemfile.lock ** to manage gems.

What is gem

・ A gem is a library. -A collection of useful functions. -By installing gem, various functions without writing code from scratch ・ There are many types of gems. (User registration function, authentication function, etc.)

What is Gemfile

The Gemfile describes the gems used in the app. You can install the listed gems by typing the command. When installing, it is possible to specify the version of the gem, otherwise it will be installed with the latest version.

Gemfile


gem 'bootstrap-sass', '3.4.1'

What is Gemfile.lock?

The gem actually installed is listed. It also shows gems that have dependencies on gems installed with the Gemfile.

Gemfile.lock


    bootsnap (1.5.1)
      msgpack (~> 1.0)
    bootstrap-sass (3.4.1)
      autoprefixer-rails (>= 5.2.1)
      sassc (>= 2.0.0)
    builder (3.2.4)

bundler installation method

Enter the following command in the terminal.

------ % gem install bundler

Check the bundler version with the following command and Also check if bundler is installed.

------ % bundle -v
Bundler version 1.17.2

bundle install Install the gem described in the Gemfile. Search the Gemfile for gems that are not in Gemfile.lock, and install the gems you find. After executing the command, the installed gems will be displayed below.

------ % bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms 
Bundler is installing for. Bundler is installing for ruby but the dependency is 
only for x86-mingw32, x86-mswin32,x64-mingw32, java. To add those platforms to 
the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 
java`.
Using rake 13.0.1
Using concurrent-ruby 1.1.7
Using i18n 1.8.5
Using minitest 5.14.2
Using thread_safe 0.3.6
...
...
...
Bundle complete! 20 Gemfile dependencies, 78 gems now installed.
Gems in the group production were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

bundle update Ignore the contents written in Gemfile.lock and install all the gems written in Gemfile. The behavior after execution is the same as bundle install.

------ % bundle update
The dependency tzinfo-data (>= 0) will be unused by any of the platforms 
Bundler is installing for. Bundler is installing for ruby but the dependency is 
only for x86-mingw32, x86-mswin32,x64-mingw32, java. To add those platforms to 
the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 
java`.
Using rake 13.0.1
Using concurrent-ruby 1.1.7
Using i18n 1.8.5
Using minitest 5.14.2
Using thread_safe 0.3.6
...
...
...
Bundle updated!
Gems in the group production were not installed.

About proper use of bundle install and bundle update

Basically, it seems better to use "bundle install". It is good to use "bundle update" when an error occurs due to a dependency. If you use "bundle update" in the production environment, the configuration of the gem will change from the development environment and test environment, and unexpected problems may occur, so be careful.

Recommended Posts

[Ruby on Rails] About bundler (for beginners)
Explanation of Ruby on rails for beginners ①
[Ruby on Rails] about has_secure_password
Explanation of Ruby on rails for beginners ⑥ ~ Creation of validation ~
Explanation of Ruby on rails for beginners ② ~ Creating links ~
Explanation of Ruby on rails for beginners ⑦ ~ Flash implementation ~
Ruby on Rails for beginners! !! Summary of new posting functions
[Procedure 1 for beginners] Ruby on Rails: Construction of development environment
Explanation of Ruby on rails for beginners ③ ~ Creating a database ~
[Ruby on Rails] About Active Record callbacks
Beginners create portfolio in Ruby on Rails
Ruby on Rails for beginners! !! Post list / detailed display function summary
Explanation of Ruby on rails for beginners ⑤ ~ Edit and delete database ~
Ruby on Rails Elementary
Ruby on Rails basics
Ruby On Rails Association
Scraping for beginners (Ruby)
Validation settings for Ruby on Rails login function
[Ruby On Rails] About RubyAws :: Sigv4 :: Errors :: MissingCredentialsError
[Ruby on Rails] Select2 introduction memo for Webpacker
[Rails] Procedure for linking databases with Ruby On Rails
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Ruby on rails learning record -2020.10.03
Portfolio creation Ruby on Rails
Ruby on rails learning record -2020.10.04
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
Ruby on Rails basic learning ①
Ruby on rails learning record-2020.10.07 ②
(For beginners) [Rails] Install Devise
Commentary on partial! --Ruby on Rails
Ruby on rails learning record-2020.10.07 ①
Cancel Ruby on Rails migration
Ruby on rails learning record -2020.10.06
Ruby on Rails validation summary
Ruby on Rails Basic Memorandum
Explanation of Ruby on rails for beginners ④ ~ Naming convention and how to use form_Tag ~
Definitely useful! Debug code for development in Ruby on Rails
A note about the seed function of Ruby on Rails
[Note] About the Fizz_Buzz problem (How Ruby on Rails works)
Ruby on Rails Overview (Beginner Summary)
[Ruby on Rails] Read try (: [],: key)
[Ruby on Rails] yarn install --check-files
Ruby on Rails variable, constant summary
Installing Ruby + Rails on Ubuntu 18.04 (rbenv)
[Ruby on Rails] Introduced paging function
Basic knowledge of Ruby on Rails
Progate Ruby on Rails5 Looking Back
How to use Ruby on Rails
[Ruby on Rails] Add / Remove Columns
Ruby on Rails Japanese-English support i18n
(Ruby on Rails6) "Erase" posted content
[Ruby on Rails] CSV output function
Ruby on Rails 6.0 environment construction memo
[Ruby on Rails] What is Bcrypt?
[Ruby on Rails] Confirmation page creation
Ruby On Rails devise routing conflict
[Ruby on Rails] Comment function implementation
[Ruby on Rails] DM, chat function