2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

『EveryDay Rails』でいきなりGem::GemNotFoundExceptionにハマりかけた話

Last updated at Posted at 2019-10-05

いきなりのGem::GemNotFoundException

Rspecをざっと勉強したいと思い、先日『Read Everyday Rails - RSpecによるRailsテスト入門』を購入しました。
Ruby on Railsを使ったポートフォリオの作成や、git等のこの本が前提としている知識はあるつもりだったのですが、
rspecをインストールするというまさかのポイントでハマりかけました・・・

gemfileにrspecを追記して, 鼻息荒くbundle installを実行。


Traceback (most recent call last):
        2: from /Users/username/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
        1: from /Users/username/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/username/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

とりあえずBundlerを疑い、bundler -vを実行

% bundle -v
Traceback (most recent call last):
        2: from /Users/username/.rbenv/versions/2.5.3/bin/bundle:23:in `<main>'
        1: from /Users/username/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/username/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

むむっ何かBundlerがおかしい

結論:Bundlerのバージョンが違う

どうやら、このエラーBundlerのバージョンが違うことで起きるみたい。

% gem install bundler -v '1.17.3'

その後、いつも通り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 gem metadata from https://rubygems.org/...............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies........
・
・
・

YEEEAH!!!!無事にインストールすることができました!

もう少し詳しく原因究明

@hirokik-0076さんの記事から孫引き
公式の説明(https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html)から抜粋

Yesterday I released Bundler 2.0 that introduced a number of breaking changes. One of the those changes was setting Bundler to require RubyGems v3.0.0. After making the release, it has become clear that lots of our users are running into issues with Bundler 2 requiring a really new version of RubyGems.

ということだそうで。このサイトにも

Can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

のエラーが出たら

gem install bundler -v '1.17.3'

を実行したら嬉しいよーと書いてありました。めでたし。

参考:
https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html
https://qiita.com/hirokik-0076/items/c5ee73f439ee53dbe45f

2
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?