Ruby 3.0 image error, undefined symbol: rb_cData

Running a command RAILS_ENV=test bin/rails db:create db:schema:load --trace in a job with the images:

circleci/ruby:3.0.0-node-browsers and circleci/postgres:12.5

currently breaks with the following trace.

#!/bin/bash -eo pipefail
RAILS_ENV=test bin/rails db:create db:schema:load --trace

rails aborted!
LoadError: /home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg_ext.so: undefined symbol: rb_cData - /home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg_ext.so
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg.rb:5:in `<main>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler/runtime.rb:66:in `block (2 levels) in require'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `each'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler/runtime.rb:61:in `block in require'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `each'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler/runtime.rb:50:in `require'
/usr/local/bundle/gems/bundler-2.2.3/lib/bundler.rb:174:in `require'
/home/circleci/my-app/config/application.rb:7:in `<main>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:49:in `require_relative'
/home/circleci/my-app/Rakefile:4:in `<main>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:326:in `block in load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:326:in `load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:104:in `block in load_rakefile'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:186:in `standard_exception_handling'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/application.rb:103:in `load_rakefile'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.0/lib/rails/commands/rake/rake_command.rb:20:in `block in perform'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/rake-13.0.3/lib/rake/rake_module.rb:59:in `with_application'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.0/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.0/lib/rails/command.rb:52:in `invoke'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/railties-6.1.0/lib/rails/commands.rb:18:in `<main>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `block in require'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.0/lib/active_support/dependencies.rb:332:in `require'
/home/circleci/my-app/bin/rails:9:in `<top (required)>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/home/circleci/my-app/vendor/bundle/ruby/3.0.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
/home/circleci/my-app/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'

Exited with code exit status 1
CircleCI received exit code 1

It looks like this was intentionally removed from Ruby 3.0:

@dluan I had the same issue as you. In my case it was caused by an upgrad from Ruby 3.0.0-preview2 to 3.0.0 while still using a cached version of pg that was compiled with 3.0.0-preview2.

Busting my gem cache and installing pg anew solved the problem for me.

1 Like