Tech Racho エンジニアの「?」を「!」に。
  • Ruby / Rails関連

Ruby 3.3.3にアップグレードするとbundle installでnet-popがインストールできない

Ruby 3.3.3がリリースされました

Ruby 3.3.3がリリースされたので、自分のRailsアプリのRubyを3.3.3にアップグレードしようとしたところ、ローカルのDockerコンテナではRailsアプリを正常に実行できたにもかかわらず、Herokuにデプロイするとbundle installの部分で以下が発生してデプロイできませんでした。

...
       Downloading net-pop-0.1.2 revealed dependencies not in the API or the lockfile
       (net-protocol (>= 0)).
       Running `bundle update net-pop` should fix the problem.
...

ruby/net-pop - GitHub

環境

  • Ruby: ruby 3.3.3 (2024-06-12 revision f1c7b6f435) +YJIT [aarch64-linux]
  • RubyGem: 3.5.13
  • Bundler: Bundler version 2.5.13 (2024-06-14 commit 5525a3d9b0)
  • Docker version 25.0.3, build 4debf41

ログ

▶全エラーログ(クリックで展開)
-----> Building on the Heroku-22 stack
-----> Using buildpacks:
       1. https://github.com/gaffneyc/heroku-buildpack-jemalloc.git
       2. heroku/metrics
       3. heroku/ruby
-----> Performing build in /app since 'build-in-app-dir' is enabled
-----> jemalloc app detected
-----> jemalloc: Installing 5.3.0 from source
       jemalloc: Downloading https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2
       jemalloc: Compiling 5.3.0
-----> jemalloc: Done
-----> HerokuRuntimeMetrics app detected
-----> Setting up .profile.d to automatically run metrics agent...
-----> Ruby app detected
-----> Installing bundler 2.5.6
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.3.3
-----> Installing dependencies using bundler 2.5.6
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Fetching gem metadata from https://rubygems.org/......
       Fetching rake 13.2.1
       Installing rake 13.2.1
       Fetching bigdecimal 3.1.8
       Fetching concurrent-ruby 1.3.3
       Fetching connection_pool 2.4.1
       Fetching drb 2.2.1
       Installing bigdecimal 3.1.8 with native extensions
       Installing connection_pool 2.4.1
       Installing drb 2.2.1
       Fetching minitest 5.23.1
       Fetching builder 3.3.0
       Installing minitest 5.23.1
       Installing builder 3.3.0
       Installing concurrent-ruby 1.3.3
       Fetching erubi 1.13.0
       Fetching racc 1.8.0
       Installing erubi 1.13.0
       Installing racc 1.8.0 with native extensions
       Fetching crass 1.0.6
       Installing crass 1.0.6
       Fetching rack 3.0.11
       Installing rack 3.0.11
       Fetching nio4r 2.7.3
       Fetching websocket-extensions 0.1.5
       Installing websocket-extensions 0.1.5
       Installing nio4r 2.7.3 with native extensions
       Fetching zeitwerk 2.6.15
       Installing zeitwerk 2.6.15
       Fetching marcel 1.0.4
       Installing marcel 1.0.4
       Fetching mini_mime 1.1.5
       Installing mini_mime 1.1.5
       Fetching net-pop 0.1.2
       Fetching msgpack 1.7.2
       Installing msgpack 1.7.2 with native extensions
       Fetching csv 3.3.0
       Installing csv 3.3.0
       Fetching google-analytics-rails 1.1.1
       Installing google-analytics-rails 1.1.1
       Fetching io-console 0.7.2
       Installing io-console 0.7.2 with native extensions
       Fetching webrick 1.8.1
       Installing webrick 1.8.1
       Fetching thor 1.3.1
       Installing thor 1.3.1
       Fetching method_source 1.1.0
       Installing method_source 1.1.0
       Fetching pagy 8.4.4
       Installing pagy 8.4.4
       Fetching pg 1.5.6
       Installing pg 1.5.6 with native extensions
       Fetching user_agent_parser 2.18.0
       Installing user_agent_parser 2.18.0
       Fetching i18n 1.14.5
       Installing i18n 1.14.5
       Fetching tzinfo 2.0.6
       Installing tzinfo 2.0.6
       Fetching rack-session 2.0.0
       Installing rack-session 2.0.0
       Fetching rack-test 2.1.0
       Installing rack-test 2.1.0
       Fetching rack-attack 6.7.0
       Installing rack-attack 6.7.0
       Fetching websocket-driver 0.7.6
       Installing websocket-driver 0.7.6 with native extensions
       Downloading net-pop-0.1.2 revealed dependencies not in the API or the lockfile
       (net-protocol (>= 0)).
       Running `bundle update net-pop` should fix the problem.
       Bundler Output: Fetching gem metadata from https://rubygems.org/......
       Fetching rake 13.2.1
       Installing rake 13.2.1
       Fetching bigdecimal 3.1.8
       Fetching concurrent-ruby 1.3.3
       Fetching connection_pool 2.4.1
       Fetching drb 2.2.1
       Installing bigdecimal 3.1.8 with native extensions
       Installing connection_pool 2.4.1
       Installing drb 2.2.1
       Fetching minitest 5.23.1
       Fetching builder 3.3.0
       Installing minitest 5.23.1
       Installing builder 3.3.0
       Installing concurrent-ruby 1.3.3
       Fetching erubi 1.13.0
       Fetching racc 1.8.0
       Installing erubi 1.13.0
       Installing racc 1.8.0 with native extensions
       Fetching crass 1.0.6
       Installing crass 1.0.6
       Fetching rack 3.0.11
       Installing rack 3.0.11
       Fetching nio4r 2.7.3
       Fetching websocket-extensions 0.1.5
       Installing websocket-extensions 0.1.5
       Installing nio4r 2.7.3 with native extensions
       Fetching zeitwerk 2.6.15
       Installing zeitwerk 2.6.15
       Fetching marcel 1.0.4
       Installing marcel 1.0.4
       Fetching mini_mime 1.1.5
       Installing mini_mime 1.1.5
       Fetching net-pop 0.1.2
       Fetching msgpack 1.7.2
       Installing msgpack 1.7.2 with native extensions
       Fetching csv 3.3.0
       Installing csv 3.3.0
       Fetching google-analytics-rails 1.1.1
       Installing google-analytics-rails 1.1.1
       Fetching io-console 0.7.2
       Installing io-console 0.7.2 with native extensions
       Fetching webrick 1.8.1
       Installing webrick 1.8.1
       Fetching thor 1.3.1
       Installing thor 1.3.1
       Fetching method_source 1.1.0
       Installing method_source 1.1.0
       Fetching pagy 8.4.4
       Installing pagy 8.4.4
       Fetching pg 1.5.6
       Installing pg 1.5.6 with native extensions
       Fetching user_agent_parser 2.18.0
       Installing user_agent_parser 2.18.0
       Fetching i18n 1.14.5
       Installing i18n 1.14.5
       Fetching tzinfo 2.0.6
       Installing tzinfo 2.0.6
       Fetching rack-session 2.0.0
       Installing rack-session 2.0.0
       Fetching rack-test 2.1.0
       Installing rack-test 2.1.0
       Fetching rack-attack 6.7.0
       Installing rack-attack 6.7.0
       Fetching websocket-driver 0.7.6
       Installing websocket-driver 0.7.6 with native extensions
       Downloading net-pop-0.1.2 revealed dependencies not in the API or the lockfile
       (net-protocol (>= 0)).
       Running `bundle update net-pop` should fix the problem.

 !
 !     Failed to install gems via Bundler.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

メッセージに従ってbundle update net-popを実行しても現象は変わりませんでした。
念のため、以下を参考にHerokuのビルドキャッシュをクリアしてみましたが、やはり変わりませんでした。

参考: How do I clear the build cache? - Heroku Help

現時点の主な情報

参考: Bug #20581: Ruby 3.3.3 install has missing deps for bundled net-pop gem - Ruby master - Ruby Issue Tracking System

参考: ruby on rails - Strange bundle update issue: disappearing net-pop (0.1.2) dependency - Stack Overflow

参考: net-protocol gets removed with ruby 3.3.3 · Issue #26 · ruby/net-pop

回避方法

netpopの#26にいくつか回避方法が投稿されていました。

少なくとも自分の場合は、#26のコメントに基づいてGemfile.lockでnet-popの依存関係にnet-protocolを追加したことで、正常にHerokuにデプロイできるようになりました(Gemfile.lockの手動変更はできれば避けたかったのですが...)。

# Gemfile.lock
...
    net-imap (0.4.12)
      date
      net-protocol
    net-pop (0.1.2)
+     net-protocol
    net-protocol (0.2.2)
      timeout
    net-smtp (0.5.0)
      net-protocol
    nio4r (2.7.3)
...

以下は成功したときのHerokuのbundle installログの抜粋です。

...
       Fetching rails_same_site_cookie 0.1.9
       Installing rails_same_site_cookie 0.1.9
       Fetching net-imap 0.4.12
       Installing net-imap 0.4.12
       Fetching net-pop 0.1.2
       Installing net-pop 0.1.2
       Fetching net-smtp 0.5.0
       Installing net-smtp 0.5.0
       Fetching loofah 2.22.0
       Installing loofah 2.22.0
       Fetching rdoc 6.7.0
       Installing rdoc 6.7.0
...

🔗 追記

その後、つい先ほど以下のissueもオープンされたという情報をBPS社内でいただきました。現象としては、net-pop gemの依存関係にnet-protocolが含まれていなかったことによるものだそうです。RubyGemやBundlerは原因ではないようです。

参考: bundle update on Ruby 3.3.3 removes net-protocol dependency of net-pop gem. · Issue #7760 · rubygems/rubygems

🔗 追記2

以下のissueがオープンされました。Ruby 3.3.4で修正の見込みです。

参考: [Bug #20581][3.3] Fix unintentional truncation for dependencies of bundled gems by hsbt · Pull Request #11006 · ruby/ruby

🔗 追記3

以下のdiscussionも類似の問題です。

参考: Rails 7 Dockerfile build fails - rubyonrails-talk - Ruby on Rails Discussions

関連記事

M1 MacでRuby 2.4〜3.2をrbenvでビルドする最小限のセットアップを全部調べた

Ruby 3.3.3がリリースされました


CONTACT

TechRachoでは、パートナーシップをご検討いただける方からの
ご連絡をお待ちしております。ぜひお気軽にご意見・ご相談ください。