LoginSignup
2
0

More than 1 year has passed since last update.

【Ruby】インストール済みのGemを確認する方法

Posted at

概要

Railsを使用しているとGemについて調べることが多いため色々な調べ方をまとめました。
※諸事情ありまして複数のバージョンが表示されています。

  • 基本のgem listです。インストール済みのGemとそのバージョンが表示されます。
$ gem list
  • 実行例
*** LOCAL GEMS ***

actioncable (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
actionmailbox (default: 6.0.2.1, 6.0.0)
actionmailer (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
actionpack (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
actiontext (default: 6.0.2.1, 6.0.0)
actionview (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
activejob (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
activemodel (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
activerecord (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
activestorage (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0)
activesupport (default: 6.0.2.1, 6.0.0, 5.2.6, 5.2.4.1, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
addressable (2.8.0, 2.7.0)
archive-zip (0.12.0)
arel (9.0.0, 8.0.0)
ast (2.4.0)
bigdecimal (default: 2.0.0, 1.4.4, default: 1.3.4)
bindex (0.8.1, 0.6.0)
bootsnap (1.7.7, 1.4.5, 1.4.2)
builder (3.2.4, 3.2.3)
・
・
・
(以下、省略)
  • -dオプションを付けるとさらに詳細な情報を得る事ができます。
$ gem list -d
  • 実行例
*** LOCAL GEMS ***

actioncable (6.0.2.1, 6.0.0, 5.2.6, 5.2.3, 5.2.0, 5.1.7, 5.1.6)
    Authors: Pratik Naik, David Heinemeier Hansson
    Homepage: https://rubyonrails.org
    License: MIT
    Installed at (6.0.2.1, default): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (6.0.0): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (5.2.6): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (5.2.3): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (5.2.0): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (5.1.7): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
                 (5.1.6): /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
    WebSocket framework for Rails.

・
・
・
(以下、省略)
  • listの後に文字を追加するとそのgemが存在するか確認できます。
$ gem list rspec
  • 実行例
*** LOCAL GEMS ***

rspec-core (default: 3.9.1, 3.9.0, 3.8.0)
rspec-expectations (3.9.0, 3.8.2)
rspec-mocks (default: 3.9.1, 3.9.0, 3.8.0)
rspec-rails (3.9.0, 3.8.2)
rspec-support (default: 3.9.2, 3.9.0, 3.8.0)
  • 他にもありますがヘルプを見たい場合はこちらで確認できます。
$ gem help list
Usage: gem list [REGEXP ...] [options]

  Options:
    -i, --[no-]installed             Check for installed gem
    -I                               Equivalent to --no-installed
    -v, --version VERSION            Specify version of gem to list
                                     for use with --installed
    -d, --[no-]details               Display detailed information of gem(s)
        --[no-]versions              Display only gem names
    -a, --all                        Display all gem versions
    -e, --exact                      Name of gem(s) to query on matches the
                                     provided STRING
        --[no-]prerelease            Display prerelease versions


  Deprecated Options:
    -u, --[no-]update-sources        Update local source cache


  Local/Remote Options:
    -l, --local                      Restrict operations to the LOCAL domain
    -r, --remote                     Restrict operations to the REMOTE domain
    -b, --both                       Allow LOCAL and REMOTE operations
    -B, --bulk-threshold COUNT       Threshold for switching to bulk
                                     synchronization (default 1000)
        --clear-sources              Clear the gem sources
    -s, --source URL                 Append URL to list of remote gem sources
    -p, --[no-]http-proxy [URL]      Use HTTP proxy for remote operations


  Common Options:
    -h, --help                       Get help on this command
    -V, --[no-]verbose               Set the verbose level of output
    -q, --quiet                      Silence command progress meter
        --silent                     Silence RubyGems output
        --config-file FILE           Use this config file instead of default
        --backtrace                  Show stack backtrace on errors
        --debug                      Turn on Ruby debugging
        --norc                       Avoid loading any .gemrc file
・
・
・
(以下、省略)
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0