質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

バージョン管理

バージョン管理はコンピューター上にファイルとして格納されているドキュメント・プログラム・その他の情報の変更履歴等を管理するものです

Q&A

1回答

5590閲覧

Could not fetch specs from https://rubygems.org/と言われてbundle installができない。

xiaoxishicheng

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

RubyGems

RubyGemsはRubyによるプログラミングのためのパッケージマネジメントツールです。ユーザはこれを使用することで、Rubyライブラリのダウンロードやアップデートや、依存関係の自動解決が可能になります。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

バージョン管理

バージョン管理はコンピューター上にファイルとして格納されているドキュメント・プログラム・その他の情報の変更履歴等を管理するものです

0グッド

0クリップ

投稿2021/09/29 21:49

編集2021/09/29 22:04

前提・実現したいこと

bundle installしたい。

発生している問題・エラーメッセージ

$ bundle install Your Gemfile lists the gem pg (= 1.1.4) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once. While it's not a problem now, it could cause errors if you change the version of one of them later. Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)> Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)> Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ due to underlying error <Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)> Could not fetch specs from https://rubygems.org/ due to underlying error <Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)>

該当のソースコード

ruby

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.7.1' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' 7gem 'rails', '~> 6.1.4', '>= 6.1.4.1' 8# Use Puma as the app server 9gem 'puma', '~> 5.0' 10# Use SCSS for stylesheets 11gem 'sass-rails', '>= 6' 12# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 13gem 'webpacker', '~> 5.0' 14# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 15gem 'turbolinks', '~> 5' 16# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 17gem 'jbuilder', '~> 2.7' 18# Use Redis adapter to run Action Cable in production 19# gem 'redis', '~> 4.0' 20# Use Active Model has_secure_password 21# gem 'bcrypt', '~> 3.1.7' 22 23# Use Active Storage variant 24# gem 'image_processing', '~> 1.2' 25 26# Reduces boot times through caching; required in config/boot.rb 27gem 'bootsnap', '>= 1.4.4', require: false 28 29group :development, :test do 30 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 31 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 32 gem 'pg', '1.1.4' 33end 34 35group :development do 36 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 37 gem 'web-console', '>= 4.1.0' 38 # Display performance information such as SQL time and flame graphs for each request in your browser. 39 # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md 40 gem 'rack-mini-profiler', '~> 2.0' 41 gem 'listen', '~> 3.3' 42 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 43 gem 'spring' 44end 45 46group :test do 47 # Adds support for Capybara system testing and selenium driver 48 gem 'capybara', '>= 3.26' 49 gem 'selenium-webdriver' 50 # Easy installation and use of web drivers to run system tests with browsers 51 gem 'webdrivers' 52end 53 54group :production do 55 gem 'pg', '1.1.4' 56end 57# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 58gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 59 60gem 'bootstrap' 61gem 'dotenv-rails'

試したこと

  • wgetでリクエストを投げて確認してみるとIPv6の場合だけ接続に失敗することを確認した。

text

1$ wget https://rubygems.org/specs.4.8.gz 2--2021-09-30 04:59:18-- https://rubygems.org/specs.4.8.gz 3Resolving rubygems.org (rubygems.org)... 2a04:4e42:200::483, 2a04:4e42::483, 2a04:4e42:400::483, ... 4Connecting to rubygems.org (rubygems.org)|2a04:4e42:200::483|:443... failed: Operation timed out. 5Connecting to rubygems.org (rubygems.org)|2a04:4e42::483|:443... failed: Operation timed out. 6Connecting to rubygems.org (rubygems.org)|2a04:4e42:400::483|:443... failed: Operation timed out. 7Connecting to rubygems.org (rubygems.org)|2a04:4e42:600::483|:443... failed: Operation timed out. 8Connecting to rubygems.org (rubygems.org)|151.101.193.227|:443... connected. 9HTTP request sent, awaiting response... 200 OK 10Length: 4485268 (4.3M) [application/octet-stream] 11Saving to: ‘specs.4.8.gz.1’

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. "When you are running gem, your gem tries IPv6 addresses first and times out on them, not having time to even try IPv4 addresses.

The solution is to lower priority of IPv6 addresses for api.rubygems.org, so that gem will try IPv4 addresses first. In order to do it, put these lines into /etc/gai.conf:

  • 以上のことから、sudo vi /etc/gai.confで、以下を記述しましたが変わりがなかったです。

text

1# Debian defaults. 2precedence ::1/128 50 3precedence ::/0 40 4precedence 2002::/16 30 5precedence ::/96 20 6precedence ::ffff:0:0/96 10 7 8# Low precedence for api.rubygems.org IPv6 addresses. 9precedence 2a04:4e42::0/32 5
  • rubygems.orgのIPv4アドレスを調べてhostsに記載もしてみましたが変わらなかったです。

text

1$ host rubygems.org 2rubygems.org has address 151.101.193.227 3rubygems.org has address 151.101.129.227 4rubygems.org has address 151.101.65.227 5rubygems.org has address 151.101.1.227 6rubygems.org has IPv6 address 2a04:4e42:600::483 7rubygems.org has IPv6 address 2a04:4e42::483 8rubygems.org has IPv6 address 2a04:4e42:200::483 9rubygems.org has IPv6 address 2a04:4e42:400::483 10rubygems.org mail is handled by 10 mxb.mailgun.org. 11rubygems.org mail is handled by 10 mxa.mailgun.org.

text

1$ sudo vi /etc/hosts 2## 3# Host Database 4# 5# localhost is used to configure the loopback interface 6# when the system is booting. Do not change this entry. 7## 127.0.0.1 localhost 8255.255.255.255 broadcasthost ::1 localhost 9 10/* 記述*/ 11151.101.129.227 rubygems.org 12151.101.65.227 rubygems.org 13151.101.1.227 rubygems.org 14151.101.193.227 rubygems.org 15
  • 以上のことをしても、変わりはなかったので、gem update --systemしてみたところ、以下のようなエラーが出ました。

text

1$ gem update --system 2ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) 3 Net::OpenTimeout: execution expired (https://rubygems.org/specs.4.8.gz)

参考

手詰まりになってわからなくなってしまいました。
よろしくお願いします。

補足情報(FW/ツールのバージョンなど)

  • ruby 2.7.1
  • Rails 6.1.4.1
  • Bundler v2.2.24

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

/etc/hostsに設定した後に上のwgetのコマンドの結果は最初から変わりないですか?

自分の環境で以下の手順で試しました。

1. /etc/hostsへ追加

151.101.193.227 rubygems.org

2. wgetで試す、Resolvingの後ろが設定するIPへ変わる

wget "https://rubygems.org/specs.4.8.gz" --2021-10-19 15:44:24-- https://rubygems.org/specs.4.8.gz Resolving rubygems.org (rubygems.org)... 151.101.193.227 Connecting to rubygems.org (rubygems.org)|151.101.193.227|:443... connected.

投稿2021/10/19 06:50

heroyct

総合スコア434

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問