Rails アプリで開発中に "docker-compose build" を実行したら以下のエラーが出てきました。
$ docker-compose build db uses an image, skipping jenkins uses an image, skipping Building web Step 1/9 : FROM ruby:2.5.3 ---> 72aaaee1eea4 Step 2/9 : RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && apt-get update && apt-get install -y nodejs --no-install-recommends && rm -rf /var/lib/apt/lists/* ---> Using cache ---> e8e5069ce436 Step 3/9 : RUN mkdir /app_name ---> Using cache ---> 06ce180c04fb Step 4/9 : ENV APP_ROOT /app_name ---> Using cache ---> 66b20f900f06 Step 5/9 : WORKDIR $APP_ROOT ---> Using cache ---> 8c07590e09d9 Step 6/9 : ADD ./Gemfile $APP_ROOT/Gemfile ---> ac4c050b96d7 Step 7/9 : ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock ---> 030a180178b2 Step 8/9 : RUN bundle install ---> Running in 95054a452e12 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/............ Your bundle is locked to msgpack (1.4.1), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of msgpack (1.4.1) has removed it. You'll need to update your bundle to a version other than msgpack (1.4.1) that hasn't been removed in order to install. ERROR: Service 'web' failed to build : The command '/bin/sh -c bundle install' returned a non-zero code: 7
原因
msgpackが怪しい。。。
Your bundle is locked to msgpack (1.4.1), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of msgpack (1.4.1) has removed it. You'll need to update your bundle to a version other than msgpack (1.4.1) that hasn't been removed in order to install.
Gemfile.lock で指定されている「msgpack」というgemを検索してみます。
以下アクセスして、問題が出ているgemを検索する。
rubygems.org
msgpackを探してみる。
解決策
エラーになっているgemのバージョンがリストになければ対象のgemをupdateする。
$ docker-compose exec web bundle update msgpack 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... Using rake 10.5.0 Using concurrent-ruby 1.1.8 Using i18n 1.8.7 Using minitest 5.14.3 Using thread_safe 0.3.6 Using tzinfo 1.2.9 Using activesupport 5.2.4.4 Using builder 3.2.4 Using erubi 1.10.0 Using mini_portile2 2.5.0 Using racc 1.5.2 Using nokogiri 1.11.1 (x86_64-linux) Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.9.0 Using rails-html-sanitizer 1.3.0 Using actionview 5.2.4.4 Using rack 2.2.3 Using rack-test 1.1.0 Using actionpack 5.2.4.4 Using nio4r 2.5.4 Using websocket-extensions 0.1.5 Using websocket-driver 0.7.3 Using actioncable 5.2.4.4 Using globalid 0.4.2 Using activejob 5.2.4.4 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailer 5.2.4.4 Using activemodel 5.2.4.4 Using arel 9.0.0 Using activerecord 5.2.4.4 Using mimemagic 0.3.5 Using marcel 0.3.3 Using activestorage 5.2.4.4 Using public_suffix 4.0.6 Using addressable 2.7.0 Using io-like 0.3.1 Using archive-zip 0.12.0 Using execjs 2.7.0 Using autoprefixer-rails 10.2.0.0 Using bindex 0.8.1 Fetching msgpack 1.4.2 (was 1.4.1) Installing msgpack 1.4.2 (was 1.4.1) with native extensions Using bootsnap 1.6.0 Using popper_js 1.16.0 Using rb-fsevent 0.10.4 Using ffi 1.14.2 Using rb-inotify 0.10.1 Using sass-listen 4.0.0 Using sass 3.7.4 Using bootstrap 4.0.0 Using bundler 1.17.3 Using byebug 11.1.3 Using regexp_parser 2.0.3 Using xpath 3.2.0 Using capybara 3.35.1 Using childprocess 3.0.0 Using chromedriver-helper 2.1.1 Using coderay 1.1.3 Using coffee-script-source 1.12.2 Using coffee-script 2.4.1 Using method_source 1.0.0 Using thor 1.1.0 Using railties 5.2.4.4 Using coffee-rails 4.2.2 Using data-confirm-modal 1.6.3 Using diff-lcs 1.4.4 Using jbuilder 2.11.2 Using ruby_dep 1.5.0 Using listen 3.1.5 Using mysql2 0.5.3 Using pry 0.13.1 Using pry-byebug 3.9.0 Using puma 3.12.6 Using sprockets 3.7.2 Using sprockets-rails 3.2.2 Using rails 5.2.4.4 Using rspec-support 3.1.2 Using rspec-core 3.1.7 Using rspec-expectations 3.1.2 Using rspec-mocks 3.1.3 Using rspec-rails 3.1.0 Using rubyzip 2.3.0 Using tilt 2.0.10 Using sass-rails 5.1.0 Using selenium-webdriver 3.142.7 Using spring 2.1.1 Using spring-watcher-listen 2.0.1 Using turbolinks-source 5.2.0 Using turbolinks 5.2.1 Using uglifier 4.2.0 Using web-console 3.7.0 Bundle updated!
再度[docker-compose build]を実行したらうまくいきました。