Closed7

Docker + Rails7.1 + Ruby3.3 の環境構築でSegmentation fault 発生。

TatsuyaaaTatsuyaaa

環境(+ ソースコード)

ローカル

  • 端末:MacBook Air M2 2022
  • CPU:Apple M2
  • OS:Sonoma 14.2.1

Docker

Docker/app/Dockerfile
FROM ruby:3.3
ARG RUBYGEMS_VERSION=3.3

WORKDIR /app
docker-composer.yml
version: '3'
services:
  db:
    image: mysql:8.0
    platform: linux/x86_64
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: database
      MYSQL_USER: admin
      MYSQL_PASSWORD: secret
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    volumes:
      - ./Docker/db/data:/var/lib/mysql
    ports:
      - 3306:3306
  app:
    build: ./docker/app
    volumes:
      - ./rails:/app
    ports:
      - 3000:3000
    tty: true
    depends_on:
      - db

railsディレクトリの中身

以下2ファイルのみ。

  • Gemfile
  • Gemfile.lock
Gemfile
source "https://rubygems.org"

gem "rails", "~> 7.1"
Gemfile.lock
# 空白ファイル
TatsuyaaaTatsuyaaa

発生経緯

ローカル
$ docker compose up -d --build

$ docker compose exec app bash
appコンテナ内
$ bundle install
# bundle install は成功する

# railsアプリ作成
$ rails new . --force --database=mysql --skip-bundle --api

Based on the specified options, the following options will also be activated:

  --skip-javascript [due to --api]
  --skip-hotwire [due to --skip-javascript]
  --skip-asset-pipeline [due to --api]

       exist
      create  README.md
      create  Rakefile
   identical  .ruby-version
   identical  config.ru
   identical  .gitignore
   identical  .gitattributes
   identical  Gemfile
         run  git init -b main from "."
warning: re-init: ignored --initial-branch=main
Reinitialized existing Git repository in /app/.git/
      create  app
      create  app/assets/config/manifest.js
      create  app/assets/stylesheets/application.css
      create  app/channels/application_cable/channel.rb
      create  app/channels/application_cable/connection.rb
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/jobs/application_job.rb
      create  app/mailers/application_mailer.rb
      create  app/models/application_record.rb
      create  app/views/layouts/application.html.erb
      create  app/views/layouts/mailer.html.erb
      create  app/views/layouts/mailer.text.erb
      create  app/assets/images
      create  app/assets/images/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/rails
      create  bin/rake
      create  bin/setup
   identical  Dockerfile
   identical  .dockerignore
      create  bin/docker-entrypoint
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/cable.yml
      create  config/puma.rb
      create  config/storage.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/content_security_policy.rb
      create  config/initializers/cors.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/new_framework_defaults_7_1.rb
      create  config/initializers/permissions_policy.rb
      create  config/locales
      create  config/locales/en.yml
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:14: [BUG] Segmentation fault at 0x0079ffffbab106c0
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux]

-- Control frame information -----------------------------------------------
c:0083 p:---- s:0416 e:000415 CFUNC  :resume
c:0082 p:0007 s:0412 E:001a40 BLOCK  /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:14 [FINISH]
c:0081 p:---- s:0409 e:000408 CFUNC  :synchronize
c:0080 p:0026 s:0405 E:0025b8 METHOD /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:12
c:0079 p:0007 s:0400 e:000399 CLASS  /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:18
c:0078 p:0025 s:0397 e:000396 TOP    /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:5 [FINISH]
c:0077 p:---- s:0394 e:000393 CFUNC  :require
c:0076 p:0023 s:0389 e:000388 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0075 p:0041 s:0383 e:000382 TOP    /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb:7 [FINISH]
c:0074 p:---- s:0380 e:000379 CFUNC  :require
c:0073 p:0023 s:0375 e:000374 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0072 p:0047 s:0369 e:000368 TOP    /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomics.rb:8 [FINISH]
c:0071 p:---- s:0366 e:000365 CFUNC  :require
c:0070 p:0023 s:0361 e:000360 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0069 p:0029 s:0355 e:000354 TOP    /usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent.rb:6 [FINISH]
c:0068 p:---- s:0352 e:000351 CFUNC  :require
c:0067 p:0023 s:0347 e:000346 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0066 p:0005 s:0341 e:000340 TOP    /usr/local/bundle/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb:4 [FINISH]
c:0065 p:---- s:0338 e:000337 CFUNC  :require_relative
c:0064 p:0025 s:0333 e:000332 TOP    /usr/local/bundle/gems/tzinfo-2.0.6/lib/tzinfo.rb:25 [FINISH]
c:0063 p:---- s:0330 e:000329 CFUNC  :require
c:0062 p:0023 s:0325 e:000324 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0061 p:0005 s:0319 e:000318 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/values/time_zone.rb:3 [FINISH]
c:0060 p:---- s:0316 e:000315 CFUNC  :require
c:0059 p:0023 s:0311 e:000310 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0058 p:0017 s:0305 e:000304 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/core_ext/time/conversions.rb:5 [FINISH]
c:0057 p:---- s:0302 e:000301 CFUNC  :require
c:0056 p:0023 s:0297 e:000296 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0055 p:0065 s:0291 e:000290 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/core_ext/object/json.rb:14 [FINISH]
c:0054 p:---- s:0288 e:000287 CFUNC  :require
c:0053 p:0023 s:0283 e:000282 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0052 p:0005 s:0277 e:000276 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/json/encoding.rb:3 [FINISH]
c:0051 p:---- s:0274 e:000273 CFUNC  :require
c:0050 p:0023 s:0269 e:000268 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0049 p:0011 s:0263 e:000262 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/json.rb:4 [FINISH]
c:0048 p:---- s:0260 e:000259 CFUNC  :require
c:0047 p:0023 s:0255 e:000254 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0046 p:0011 s:0249 e:000248 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/messages/metadata.rb:4 [FINISH]
c:0045 p:---- s:0246 e:000245 CFUNC  :require_relative
c:0044 p:0011 s:0241 e:000240 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/messages/codec.rb:4 [FINISH]
c:0043 p:---- s:0238 e:000237 CFUNC  :require
c:0042 p:0023 s:0233 e:000232 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0041 p:0023 s:0227 e:000226 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/message_encryptor.rb:6 [FINISH]
c:0040 p:---- s:0224 e:000223 CFUNC  :require
c:0039 p:0023 s:0219 e:000218 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0038 p:0017 s:0213 e:000212 TOP    /usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/encrypted_file.rb:5 [FINISH]
c:0037 p:---- s:0210 e:000209 CFUNC  :require
c:0036 p:0023 s:0205 e:000204 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0035 p:0017 s:0199 e:000198 TOP    /usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb:5 [FINISH]
c:0034 p:---- s:0196 e:000195 CFUNC  :require
c:0033 p:0023 s:0191 e:000190 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0032 p:0017 s:0185 e:000184 TOP    /usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/master_key/master_key_generator.rb:5 [FINISH]
c:0031 p:---- s:0182 e:000181 CFUNC  :require
c:0030 p:0023 s:0177 e:000176 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0029 p:0025 s:0171 e:000170 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/app/app_generator.rb:180 [FINISH]
c:0028 p:---- s:0166 e:000165 CFUNC  :public_send
c:0027 p:0020 s:0161 e:000160 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/app_base.rb:150
c:0026 p:0005 s:0155 e:000154 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/app/app_generator.rb:384
c:0025 p:0054 s:0151 e:000150 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28
c:0024 p:0040 s:0143 e:000142 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127
c:0023 p:0005 s:0136 e:000135 BLOCK  /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134 [FINISH]
c:0022 p:---- s:0131 e:000130 IFUNC
c:0021 p:---- s:0128 e:000127 CFUNC  :each
c:0020 p:---- s:0125 e:000124 CFUNC  :map
c:0019 p:0008 s:0121 e:000120 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134
c:0018 p:0086 s:0117 e:000116 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/group.rb:232
c:0017 p:0044 s:0106 e:000105 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584
c:0016 p:0012 s:0099 e:000098 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/commands/application/application_command.rb:28
c:0015 p:0054 s:0094 e:000093 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28
c:0014 p:0040 s:0086 e:000085 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127
c:0013 p:0031 s:0079 e:000078 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/command/base.rb:178
c:0012 p:0213 s:0072 e:000071 METHOD /usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527
c:0011 p:0048 s:0059 e:000058 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/command/base.rb:73
c:0010 p:0025 s:0052 e:000051 BLOCK  /usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:71
c:0009 p:0015 s:0049 e:000048 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:149
c:0008 p:0048 s:0043 e:000042 METHOD /usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:69
c:0007 p:0075 s:0032 E:0000e0 TOP    /usr/local/bundle/gems/railties-7.1.3/lib/rails/cli.rb:21 [FINISH]
c:0006 p:---- s:0029 e:000028 CFUNC  :require
c:0005 p:0023 s:0024 e:000023 METHOD <internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127
c:0004 p:0042 s:0018 e:000017 TOP    /usr/local/bundle/gems/railties-7.1.3/exe/rails:10 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC  :load
c:0002 p:0078 s:0008 E:001830 EVAL   /usr/local/bundle/bin/rails:25 [FINISH]
c:0001 p:0000 s:0003 E:000350 DUMMY  [FINISH]

-- Ruby level backtrace information ----------------------------------------
/usr/local/bundle/bin/rails:25:in `<main>'
/usr/local/bundle/bin/rails:25:in `load'
/usr/local/bundle/gems/railties-7.1.3/exe/rails:10:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/cli.rb:21:in `<top (required)>'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:69:in `invoke'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:149:in `with_argv'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/command.rb:71:in `block in invoke'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/command/base.rb:73:in `perform'
/usr/local/bundle/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/command/base.rb:178:in `invoke_command'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/commands/application/application_command.rb:28:in `perform'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/group.rb:232:in `dispatch'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `invoke_all'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `map'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `each'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:134:in `block in invoke_all'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/app/app_generator.rb:384:in `create_master_key'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/app_base.rb:150:in `build'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/app_base.rb:150:in `public_send'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/app/app_generator.rb:180:in `master_key'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/master_key/master_key_generator.rb:5:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/railties-7.1.3/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb:5:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/encrypted_file.rb:5:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/message_encryptor.rb:6:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/messages/codec.rb:4:in `<top (required)>'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/messages/codec.rb:4:in `require_relative'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/messages/metadata.rb:4:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/json.rb:4:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/json/encoding.rb:3:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/core_ext/object/json.rb:14:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/core_ext/time/conversions.rb:5:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/activesupport-7.1.3/lib/active_support/values/time_zone.rb:3:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/tzinfo-2.0.6/lib/tzinfo.rb:25:in `<top (required)>'
/usr/local/bundle/gems/tzinfo-2.0.6/lib/tzinfo.rb:25:in `require_relative'
/usr/local/bundle/gems/tzinfo-2.0.6/lib/tzinfo/string_deduper.rb:4:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent.rb:6:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomics.rb:8:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/reentrant_read_write_lock.rb:7:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
<internal:/usr/local/lib/ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:127:in `require'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:5:in `<top (required)>'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:18:in `<module:Concurrent>'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:12:in `mutex_owned_per_thread?'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:12:in `synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:14:in `block in mutex_owned_per_thread?'
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:14:in `resume'

-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1

-- Machine register context ------------------------------------------------
  x0: 0x0000aaaaf65aab50  x1: 0x0000aaaaf70a72a0  x2: 0x0000ffffc9d14cf0
  x3: 0x0000ffffa080ff60  x4: 0x0000ffffa0810018  x5: 0x0000ffffa0830000
  x6: 0x0000ffffbb05bb88  x7: 0x0000000000000000 x18: 0x00000000000003f3
 x19: 0x0000000000000000 x20: 0x0000000000000000 x21: 0x0000000000000000
 x22: 0x0000000000000000 x23: 0x0000000000000000 x24: 0x0000000000000000
 x25: 0x0000000000000000 x26: 0x0000000000000000 x27: 0x0000000000000000
 x28: 0x0000000000000000 x29: 0x0000000000000000  sp: 0x0000ffffa0810000
 fau: 0x0079ffffbab106c0

-- C level backtrace information -------------------------------------------
Segmentation fault

この後、rails 関係が完全に使えなくなってしまった。

appコンテナ内
$ rails -v

bin/rails:3:in `require_relative': cannot load such file -- /app/config/boot (LoadError)
	from bin/rails:3:in `<main>'

$ rails new . --force --database=mysql --skip-bundle

bin/rails:3:in `require_relative': cannot load such file -- /app/config/boot (LoadError)
	from bin/rails:3:in `<main>'
TatsuyaaaTatsuyaaa

仕切り直しということで、以下を実施。

  • コンテナを削除。
  • railsディレクトリの中身を、Gemfile と Gemfile.lock のみの状態に戻す。
  • Gemfile の中身も、rails new 実行前の状態に戻す。
  • Gemfile.lock の中身も、rails new 実行前の空白状態に戻す。
TatsuyaaaTatsuyaaa

Rubyが最新すぎるが故に、何かしらうまく行ってないのか?という甘めの予想。

Ruby 3.2 に落として、もう一度やり直す。
Dockerfileを修正。

Dockerfile
FROM ruby:3.2
ARG RUBYGEMS_VERSION=3.2

WORKDIR /app

修正後は、もう一度 Dockerビルドを含めてコンテナを立ち上げ直す。

そして、同じように bundle install 後に、 rails new . --force --database=mysql --skip-bundle --api を実行。

結果は、無事成功した。

TatsuyaaaTatsuyaaa

これで一旦めでたしめでたしでも良いが、エラーの発生箇所をよくよく読んでみると、気になる内容が。

気になるエラーを抜粋
/usr/local/bundle/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/atomic/lock_local_var.rb:14: [BUG] Segmentation fault at 0x0079ffffbab106c0
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux]

aarch64-linux が凄く気になって、MySQL8.0のコンテナを作った時に遭遇した WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested のエラーを思い出した。

この時の対処法が、 docker-compose.yml にも書いてある platform: linux/x86_64 の一行。

これを appコンテナ側でも指定すれば、もしかしたら動くのかも...?

TatsuyaaaTatsuyaaa

もう一度仕切り直しをして、Ruby, RubyGems のバージョンを 3.3に戻し、docker-compose.yml を以下のように修正してみた。

docker-compose.yml
version: '3'
services:
  db:
    image: mysql:8.0
    platform: linux/x86_64 # M1, M2対策
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: todo
      MYSQL_USER: admin
      MYSQL_PASSWORD: secret
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
    volumes:
      - ./Docker/db/data:/var/lib/mysql
    ports:
      - 3306:3306
  app:
    build: ./docker/app
    platform: linux/x86_64 # M1, M2対策 ← ここを追加
    volumes:
      - ./rails:/app
    ports:
      - 3000:3000
    tty: true
    depends_on:
      - db

ここまで準備が整ったところで、もう一度 dockerコンテナを立ち上げ、内部で rails new を試すと、無事成功。

TatsuyaaaTatsuyaaa

雑なまとめ

M1, M2 Mac を使用する人は、何か問題起きたらとりあえず platform: linux/x86_64 を試すと上手くいくことあるかも。

このスクラップは2024/02/03にクローズされました