Help us understand the problem. What is going on with this article?

rails5.2 bundle installがこけるので原因を調査してみた

More than 1 year has passed since last update.

rails newしたのですが、bundle installの部分でこけました。

$ 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`.
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Could not fetch specs from https://rubygems.org/

ググったらgem updateしろと出てきたのでしてみましたが、こちらもNG

$ gem update -V --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
    timed out (https://api.rubygems.org/specs.4.8.gz)

wgetもできない

$ wget https://api.rubygems.org/specs.4.8.gz
--2018-11-28 21:49:23--  https://api.rubygems.org/specs.4.8.gz
api.rubygems.org (api.rubygems.org) をDNSに問いあわせています... 2a04:4e42:400::70, 2a04:4e42::70, 2a04:4e42:200::70, ...
api.rubygems.org (api.rubygems.org)|2a04:4e42:400::70|:443 に接続しています... 失敗しました: Operation timed out.
api.rubygems.org (api.rubygems.org)|2a04:4e42::70|:443 に接続しています... 失敗しました: Operation timed out.
api.rubygems.org (api.rubygems.org)|2a04:4e42:200::70|:443 に接続しています... ^C

IPv6での通信ができないのか?と思いググったらそうっぽい

api.rubygems.org is currently experiencing issues with IPv6 setup: this hostname has 4 IPv6 addresses, but responds on neither of them. Neither to ping, nor to TCP connection attempts. "

https://stackoverflow.com/questions/49800432/gem-cannot-access-rubygems-org

4つのIPv6アドレスを持っているがどれも応答しないとのこと

rubygems.orgのIPv4アドレスを調べてhostsに記載して無事解決!

$ host rubygems.org
rubygems.org has address 151.101.128.70
rubygems.org has address 151.101.64.70
rubygems.org has address 151.101.0.70
rubygems.org has address 151.101.192.70
rubygems.org has IPv6 address 2a04:4e42:600::70
rubygems.org has IPv6 address 2a04:4e42::70
rubygems.org has IPv6 address 2a04:4e42:400::70
rubygems.org has IPv6 address 2a04:4e42:200::70
rubygems.org mail is handled by 10 mxa.mailgun.org.
rubygems.org mail is handled by 10 mxb.mailgun.org.
$ sudo vi /etc/hosts
$ bundle install
Fetching source index from https://rubygems.org/

--- 省略! ---

Bundle complete! 19 Gemfile dependencies, 81 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away