LoginSignup
9
17

More than 5 years have passed since last update.

Windows10にRubyGemsをインストールする方法

Last updated at Posted at 2017-06-25

RubyGemsとは

ざっくり和訳 : RubyGemsを使って簡単にRubyを使ったソフトウェアをインストール・アンインストールできます。

The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” and contains a package Ruby application or library.
Guides - RubyGems Guides

※. 英語はとても弱いのでどなたか初心者向け一言和訳があれば教えてください。

環境

  • OS : Windows10 64bit
    • メモリ : 8.00GB
  • インストールするRuby : ruby 2.4.1p111
  • インストールするRubyGems : 2.6.11

RubyGemsがインストールされているかを確認する(確実にインストールされていない場合は飛ばす)

物忘れが激しいのでインストールしたようなしてないような・・・忘れたので確認します。
コマンドプロンプトなどコマンドラインツールで $ gem -vを打つとわかります。

$ ruby -v
bash: ryby: command not found
$ gem -v
bash: gem: command not found

Ruby も RubyGems もインストールされていません。

RubyInstallerをサイトからダウンロードする

RubyInstaller for Windows からインストールするPCに合ったほしいバージョンを選んでダウンロードします。
WS000001.JPG

今回は 64bit版最新バージョンを選びました。

インストーラを起動してRubyGemsをインストールする

  1. ダウンロードしたインストーラを起動して同意します。WS000002.JPG
  2. インストール場所を指定してインストールします。WS000003.JPG

  3. インストールできました。WS000004.JPGWS000000.JPG

インストールされたことを確認する

$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
$ gem -v
2.6.11

おまけ

インストールが終わったと思ったらなんか聞かれました。

 _____       _           _____           _        _ _         ___
|  __ \     | |         |_   _|         | |      | | |       |__ \
| |__) |   _| |__  _   _  | |  _ __  ___| |_ __ _| | | ___ _ __ ) |
|  _  / | | | '_ \| | | | | | | '_ \/ __| __/ _` | | |/ _ \ '__/ /
| | \ \ |_| | |_) | |_| |_| |_| | | \__ \ || (_| | | |  __/ | / /_
|_|  \_\__,_|_.__/ \__, |_____|_| |_|___/\__\__,_|_|_|\___|_||____|
                    __/ |           _
                   |___/          _|_ _  __   | | o __  _| _     _
                                   | (_) |    |^| | | |(_|(_)\^/_>

   1 - MSYS2 base installation
   2 - MSYS2 repository update
   3 - MSYS2 and MINGW development toolchain
Which components shall be installed? [1,2,3] 

MSYS2って何?

ざっくり和訳 : パッケージ管理システムのパックマンとbashとAutotoolsがセットになったMSYSの書き直し版です。
At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.
It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.
MSYS2 installer

※. 英語はとても弱いのでどなたか初心者向け一言和訳があれば教えてください。

MSYSとは・・・Windows上で動作するUnixシェルやテキスト操作ユーティリティ、ソースコードパッチ用ツール, アーカイブツールを統合したパッケージである。 MSYS - Wikipedia

Autotoolsとは・・・使用することにより、多種多様なUNIX互換環境にパッケージを対応させることが容易になる。 Autotools - Wikipedia

ずいぶん前にRubyGemsをインストールしたときはこんなんでなかった気がします。
ちょっとググってみたらRuby2.4からRubyInstallerからRubyInstaller2へ新しくなったそうです。

これまで必要となったことがないのでいらないのですが、初めて知ったものなので動かしてみます。
使わない場合は Ctrl + C で終了します。

MSYS2をインストールしてみる

   1 - MSYS2 base installation
   2 - MSYS2 repository update
   3 - MSYS2 and MINGW development toolchain
Which components shall be installed? [1,2,3] 1 <--------------- 「MSYS2 base installation」を選択します。

MSYS2 seems to be unavaiable
Download http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20161025.exe
  to C:\Users\m-uki\AppData\Local\Temp/msys2-x86_64-20161025.exe
Downloading msys2-x86_64-20161025.exe (100%)
Verify integrity of msys2-x86_64-20161025.exe ... OK
Run the MSYS2 installer ...
> C:\Users\m-uki\AppData\Local\Temp/msys2-x86_64-20161025.exe
  1. ダイアログが表示されます。WS000001.JPG
  2. インストール場所を選択する。WS000002.JPGWS000003.JPG
  3. ダイアログを閉じるとターミナルが起動しましたが、使わないので $ logout で閉じます。

リポジトリをアップデートしてみる

Run the MSYS2 installer ...
> C:\Users\m-uki\AppData\Local\Temp/msys2-x86_64-20161025.exe
 Success

   1 - MSYS2 base installation
   2 - MSYS2 repository update
   3 - MSYS2 and MINGW development toolchain
Which components shall be installed? [] 2 <---------- 「MSYS2 repository update」を選択します。

MSYS2 seems to be already installed
MSYS2 repository update ...
> pacman -Sy --needed --noconfirm
:: Synchronizing package databases...
 mingw32                                        341.6 KiB  1029K/s 00:00 [#######################################] 100%
 mingw32.sig                                     96.0   B  31.2K/s 00:00 [#######################################] 100%
 mingw64                                        341.7 KiB   248K/s 00:01 [#######################################] 100%
 mingw64.sig                                     96.0   B  31.2K/s 00:00 [#######################################] 100%
 msys                                           150.2 KiB   659K/s 00:00 [#######################################] 100%
 msys.sig                                        96.0   B  31.2K/s 00:00 [#######################################] 100%
MSYS2 repository update succeeded

   1 - MSYS2 base installation
   2 - MSYS2 repository update
   3 - MSYS2 and MINGW development toolchain
Which components shall be installed? []

tooolchainしてみる

   3 - MSYS2 and MINGW development toolchain
Which components shall be installed? [] 3 <-------------「MSYS2 and MINGW development toolchain」を選択します。

MSYS2 seems to be already installed
Install MSYS2 and MINGW development toolchain ...
> pacman -S --needed --noconfirm autoconf autoconf2.13 autogen automake-wrapper automake1.10 automake1.11 automake1.12 automake1.13 automake1.14 automake1.15 automake1.6 automake1.7 automake1.8 automake1.9 diffutils file gawk grep libtool m4 make patch pkg-config sed texinfo texinfo-tex wget mingw-w64-x86_64-binutils mingw-w64-x86_64-crt-git mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-headers-git mingw-w64-x86_64-libmangle-git mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-make mingw-w64-x86_64-pkg-config mingw-w64-x86_64-tools-git mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-winstorecompat-git
resolving dependencies...
looking for conflicting packages...

Packages (59) db-5.3.28-2  gdbm-1.11-3  glib2-2.48.2-1  libgc-7.6.0-1  libgcrypt-1.6.4-1  libgdbm-1.11-3
              libguile-2.0.14-1  libltdl-2.4.6-2  libunistring-0.9.7-1  libxslt-1.1.29-1
              mingw-w64-x86_64-bzip2-1.0.6-6  mingw-w64-x86_64-gmp-6.1.2-1  mingw-w64-x86_64-isl-0.18-1
              mingw-w64-x86_64-libiconv-1.15-1  mingw-w64-x86_64-mpc-1.0.3-2  mingw-w64-x86_64-mpfr-3.1.5.p1-1
              mingw-w64-x86_64-windows-default-manifest-6.4-3  mingw-w64-x86_64-zlib-1.2.11-1  perl-5.24.1-3
              tar-1.29-1  autoconf-2.69-3  autoconf2.13-2.13-2  autogen-5.18.12-1  automake-wrapper-10-1
              automake1.10-1.10.3-3  automake1.11-1.11.6-3  automake1.12-1.12.6-3  automake1.13-1.13.4-4
              automake1.14-1.14.1-3  automake1.15-1.15-2  automake1.6-1.6.3-2  automake1.7-1.7.9-2  automake1.8-1.8.5-3
              automake1.9-1.9.6-2  diffutils-3.5-1  file-5.30-1  gawk-4.1.4-2  grep-3.0-1  libtool-2.4.6-2  m4-1.4.18-1
              make-4.2.1-1  mingw-w64-x86_64-binutils-2.28-1  mingw-w64-x86_64-crt-git-5.0.0.4834.33ee6cab-1
              mingw-w64-x86_64-gcc-6.3.0-3  mingw-w64-x86_64-gcc-libs-6.3.0-3
              mingw-w64-x86_64-headers-git-5.0.0.4836.670da35c-1  mingw-w64-x86_64-libmangle-git-5.0.0.4760.d3089b5-1
              mingw-w64-x86_64-libwinpthread-git-5.0.0.4833.f057c525-1  mingw-w64-x86_64-make-4.2.1-1
              mingw-w64-x86_64-pkg-config-0.29.2-1  mingw-w64-x86_64-tools-git-5.0.0.4760.d3089b5-1
              mingw-w64-x86_64-winpthreads-git-5.0.0.4833.f057c525-1
              mingw-w64-x86_64-winstorecompat-git-5.0.0.4760.d3089b5-1  patch-2.7.5-1  pkg-config-0.29.2-1  sed-4.4-2
              texinfo-6.3-1  texinfo-tex-6.3-1  wget-1.19.1-1

Total Download Size:    80.45 MiB
Total Installed Size:  476.19 MiB
Net Upgrade Size:      461.40 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
 mingw-w64-x86_64-libiconv-1.15-1-any           613.1 KiB   228K/s 00:03 [#######################################] 100%
 mingw-w64-x86_64-gmp-6.1.2-1-any               486.0 KiB   331K/s 00:01 [#######################################] 100

<省略>

(59/59) checking available disk space                                    [#######################################] 100%
:: Processing package changes...
( 1/59) upgrading gawk                                                   [#######################################] 100%

<省略>

Optional dependencies for glib2
    gamin: for gio fam module
    python2: for gdbus-codegen and gtester-report
(35/59) installing pkg-config                                            [#######################################] 100%

<省略>

(59/59) installing mingw-w64-x86_64-winstorecompat-git                   [#######################################] 100%
Install MSYS2 and MINGW development toolchain succeeded
9
17
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
9
17