Could not find activesupport-5.2.2 in any of the sources

Ruby on railsDocker
Rails5 でbundle installをするときにバージョンコンフリクトでつまったメモ - Qiita
Rails tutorialも標準でRails 5に対応しましたね。今回bundle installをする時バージョンコンフリクトで詰まったので自分用のメモ通常通りRails5をGemでインスト…

またRailsの作成時にはまりました。エラーは以下です。

Could not find activesupport-5.2.2 in any of the sources
スポンサーリンク

事象

まずインストールされているか確認します。

% gem list

*** LOCAL GEMS ***

actioncable (6.0.3.4)
actionmailbox (6.0.3.4)
actionmailer (6.0.3.4)
actionpack (6.0.3.4, 5.2.3, 5.2.2, 5.1.7)
actiontext (6.0.3.4)
actionview (6.0.3.4, 5.2.3, 5.2.2, 5.1.7)
activejob (6.0.3.4)
activemodel (6.0.3.4, 5.2.3, 5.2.2, 5.1.7)
activerecord (6.0.3.4)
activestorage (6.0.3.4)
activesupport (6.0.3.4, 5.2.3, 5.2.2, 5.1.7)

インストールされていますが、複数バージョンありますね。。

これが原因なのかな?

そして見つけたのがこの記事!!!
ありがてー

まずは6.0.3.4を削除してみました。

gem uninstall activesupport -v '6.0.3.4'

ou have requested to uninstall the gem:
	activesupport-6.0.3.4

actionmailbox-6.0.3.4 depends on activesupport (= 6.0.3.4)
actionpack-6.0.3.4 depends on activesupport (= 6.0.3.4)
actiontext-6.0.3.4 depends on activesupport (= 6.0.3.4)
actionview-6.0.3.4 depends on activesupport (= 6.0.3.4)
activejob-6.0.3.4 depends on activesupport (= 6.0.3.4)
activemodel-6.0.3.4 depends on activesupport (= 6.0.3.4)
activerecord-6.0.3.4 depends on activesupport (= 6.0.3.4)
rails-6.0.3.4 depends on activesupport (= 6.0.3.4)
railties-6.0.3.4 depends on activesupport (= 6.0.3.4)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled activesupport-6.0.3.4

変わらない。。。

よくみたら、エラーの内容が記事と違った。。

ここで以下の記事を発見。。。

どのrailsが使われているか確認してみた。

% which rails
/usr/local/bin/rails

ローカルのものが使われている。

% bundle exec gem list
Could not find activesupport-5.2.2 in any of the sources
Run `bundle install` to install missing gems.

bundle exec でもエラーが出る。

rubyのバージョンもみてみる。

which ruby
/usr/bin/ruby

えーーーー
前設定したはずなのに、rbenvが指定されていない。。。

こちらは以下で解決しました。

でもまだ以下のエラーが出る

docker-compose run web rails new . --force --database=mysql --skip-bundle

Creating sample_web_run ... done
Could not find activesupport-5.2.2 in any of the sources
Run `bundle install` to install missing gems.

詰まったので、docker-compose buildしてみると成功した!!
なんだったんだ。。。

docker-compose upを実行すると今度は。。。

cannot load such file -- bootsnap/setup (LoadError)

何かの記事をみて以下を実行してみました。

bundle exec rails webpacker:install:angular

すると違うエラー。。。

%  docker-compose run web rails new . --force --database=mysql --skip-bundle

Creating sample_web_run ... done
Could not find msgpack-1.3.3 in any of the sources
Run `bundle install` to install missing gems.

一度dockerを削除して再度実行すると正常にrails newできました!!

再度docker-compose buildして、docker-compose upしていきます。

今度は以下のエラー。。。どうもrailsのバージョンがおかしいというエラーっぽい。
今でより具体的でエラーなのに嬉しい笑

web_1  | 	 3: from /myapp/config/application.rb:9:in `<main>'
web_1  | 	 2: from /myapp/config/application.rb:10:in `<module:Myapp>'
web_1  | 	 1: from /myapp/config/application.rb:12:in `<class:Application>'
web_1  | /usr/local/bundle/gems/railties-5.2.2/lib/rails/application/configuration.rb:118:in `load_defaults': Unknown version "6.0" (RuntimeError)
dokosumu_web_1 exited with code 1

config>application.rbないをみてみると以下のように指定されている。

  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 6.0

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration can go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded after loading
    # the framework and any gems in your application.
  end

Gemfileでは以下のように指定しているので、これが原因と疑う。

gem 'rails', '5.2.2'

application.rbで5.2.2に設定しました。

    config.load_defaults 5.2.2

今度は以下のエラー

web_1  | /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': /myapp/config/application.rb:13: unexpected fraction part after numeric literal (SyntaxError)
web_1  |     config.load_defaults 5.2.2
web_1  |                          ^~~

2桁は指定できないのかな?以下で設定し、再度docker-compose upする。

    config.load_defaults 5.2

application.rbは通りました。今度はlistenというGemがないみたい。

web_1  | /usr/local/bundle/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile (LoadError)

とりあえずGemをインストールします。

gem install listen
bundle install

今度は違うのが見つからない。。。。
なんか永遠に続く気がしてきた。。。。

Could not find ffi-1.13.1 in any of the sources

またインストールして、再ビルド。。。

gem install listen ffi
docker-compose build

今度こそ!!!!!

docker-compose up

うまくいったーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー!!!!!!!!!!!!!!!!!!!!!!!

いやー
諦めそうになったけど、結構達成感あります。

環境構築で挫折しそうな方、一緒に頑張りましょう

フリーランスを目指すなら【テックパートナーズカレッジ】

未経験者向けWEBスクール【SHElikes】

コメント

タイトルとURLをコピーしました