環境
ホストOS:Big Sur(M1 mac)
コンテナ内OS Debian 10.5
Docker
rails 6.0.4.7
ruby 2.7.1
困っていること
表題の通りrails db:create時にGLIBC_2.29もしくはnokogiriが不足?しているエラーが発生しています。
エラーは以下の通りです。
調べたところM1搭載のmacではよくある事象らしくいくつか当てはまるような記事もありましたが、
その方法では解決に至っていません。
XXXXX xxx$ docker-compose run web rails db:create Creating network "portfolio_20220406_default" with the default driver Creating portfolio_20220406_db_1 ... done Creating portfolio_20220406_web_run ... done ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system with glibc < 2.17: /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/2.7/nokogiri.so) - /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/2.7/nokogiri.so If that's the case, then please install Nokogiri via the `ruby` platform gem: gem install nokogiri --platform=ruby or: bundle config set force_ruby_platform true Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help. rails aborted! LoadError: /lib/aarch64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/2.7/nokogiri.so) - /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/2.7/nokogiri.so /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/extension.rb:7:in `require_relative' /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri/extension.rb:7:in `<main>' /usr/local/bundle/gems/nokogiri-1.13.3-aarch64-linux/lib/nokogiri.rb:10:in `require_relative ----省略---- /usr/local/bundle/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' /usr/local/bundle/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' bin/rails:9:in `<main>' (See full trace by running task with --trace) ERROR: 1
確認したこと
以下エラーメッセージにあったコマンドについてはDockerfileのbundle installの直前に組み込んでみました。
ビルドは通りbundle installまで問題なく完了しました。しかし再度db:createしても同じエラーが発生します。
RUN bundle config set force_ruby_platform true もしくは RUN gem install nokogiri --platform=ruby
GLIBCのバージョン確認
$ docker-compose run web ldd --version Creating portfolio_20220406_web_run ... done ldd (Debian GLIBC 2.28-10) 2.28 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper
nokogiriのバージョン確認
$ docker-compose run web gem list | grep noko Creating portfolio_20220406_web_run ... done nokogiri (1.13.3 aarch64-linux)
Docker関連ファイル
Dockerfile
FROM ruby:2.7.1 RUN apt-get update -qq && \ apt-get install -y build-essential \ libpq-dev \ nodejs \ && rm -rf /var/lib/apt/lists/* RUN mkdir /app ENV APP_ROOT /app WORKDIR $APP_ROOT ADD ./Gemfile $APP_ROOT/Gemfile ADD ./Gemfile.lock $APP_ROOT/Gemfile.lock RUN bundle install
docker
version: '3' services: web: build: ./api command: bundle exec rails s -p 3000 -b '0.0.0.0' ports: - '3000:3000' depends_on: - db volumes: - ./api:/app - bundle:/usr/local/bundle tty: true stdin_open: true db: platform: linux/x86_64 # M1チップ対応のため追記 image: mysql:5.7 volumes: - mysql_data:/var/lib/mysql/ environment: MYSQL_ROOT_PASSWORD: password ports: - '3306:3306' front: build: ./front volumes: - ./front:/app ports: - '8080:8080' tty: true stdin_open: true command: npm run serve volumes: mysql_data: bundle:
※front部分のDockerfileを読み込むところまで行っていないのであえて記載しません。
Gemfile関連のファイル
GemfileGemfile
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' gem 'rails', '~> 6.0.4', '>= 6.0.4.7' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4' # Use Puma as the app server gem 'puma', '~> 4.1' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible gem 'rack-cors' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do gem 'listen', '~> 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Gemfile.lock
GEM remote: https://rubygems.org/ specs: actioncable (6.0.4.7) actionpack (= 6.0.4.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.0.4.7) actionpack (= 6.0.4.7) activejob (= 6.0.4.7) activerecord (= 6.0.4.7) activestorage (= 6.0.4.7) activesupport (= 6.0.4.7) mail (>= 2.7.1) actionmailer (6.0.4.7) actionpack (= 6.0.4.7) actionview (= 6.0.4.7) activejob (= 6.0.4.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.0.4.7) actionview (= 6.0.4.7) activesupport (= 6.0.4.7) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.0.4.7) actionpack (= 6.0.4.7) activerecord (= 6.0.4.7) activestorage (= 6.0.4.7) activesupport (= 6.0.4.7) nokogiri (>= 1.8.5) actionview (6.0.4.7) activesupport (= 6.0.4.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) activejob (6.0.4.7) activesupport (= 6.0.4.7) globalid (>= 0.3.6) activemodel (6.0.4.7) activesupport (= 6.0.4.7) activerecord (6.0.4.7) activemodel (= 6.0.4.7) activesupport (= 6.0.4.7) activestorage (6.0.4.7) actionpack (= 6.0.4.7) activejob (= 6.0.4.7) activerecord (= 6.0.4.7) marcel (~> 1.0.0) activesupport (6.0.4.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) bootsnap (1.11.1) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) concurrent-ruby (1.1.10) crass (1.0.6) erubi (1.10.0) ffi (1.15.5) globalid (1.0.0) activesupport (>= 5.0) i18n (1.10.0) concurrent-ruby (~> 1.0) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.16.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.15.0) msgpack (1.5.0) mysql2 (0.5.3) nio4r (2.5.8) nokogiri (1.13.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) puma (4.3.12) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) rack-cors (1.1.1) rack (>= 2.0.0) rack-test (1.1.0) rack (>= 1.0, < 3) rails (6.0.4.7) actioncable (= 6.0.4.7) actionmailbox (= 6.0.4.7) actionmailer (= 6.0.4.7) actionpack (= 6.0.4.7) actiontext (= 6.0.4.7) actionview (= 6.0.4.7) activejob (= 6.0.4.7) activemodel (= 6.0.4.7) activerecord (= 6.0.4.7) activestorage (= 6.0.4.7) activesupport (= 6.0.4.7) bundler (>= 1.3.0) railties (= 6.0.4.7) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.2) loofah (~> 2.3) railties (6.0.4.7) actionpack (= 6.0.4.7) activesupport (= 6.0.4.7) method_source rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) rake (13.0.6) rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) thor (1.2.1) thread_safe (0.3.6) tzinfo (1.2.9) thread_safe (~> 0.1) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) zeitwerk (2.5.4) PLATFORMS ruby DEPENDENCIES bootsnap (>= 1.4.2) byebug listen (~> 3.2) mysql2 (>= 0.4.4) puma (~> 4.1) rack-cors rails (~> 6.0.4, >= 6.0.4.7) spring spring-watcher-listen (~> 2.0.0) tzinfo-data RUBY VERSION ruby 2.7.1p83 BUNDLED WITH 2.1.4
教えて頂きたいこと
自分としてはGLIBCについてエラーで不足しているのは2.29、実際に入っているのは2.28という点が怪しいかなとバージョンアップなどの対応を試しているところです。
上記のようにまだ模索中ではあるのですが、かなり時間がかかっており並行して他の解決策についてご教示いただけると幸いです。
すでに参考にしているリンク
https://abillyz.com/watanabe/studies/244
https://nokogiri.org/tutorials/installing_nokogiri.html#supported-platforms
https://teratail.com/questions/hu67fbfeiwvi8r
まだ回答がついていません
会員登録して回答してみよう