Error during installation of dpl - Failed to build gem native extension

During installation of dpl the following error occurs:

$ rvm use $(travis_internal_ruby) --fuzzy do ruby -S gem uninstall -aIx dpl
Gem 'dpl' is not installed
2.30s$ rvm use $(travis_internal_ruby) --fuzzy do ruby -S gem install dpl --pre
Successfully installed mime-0.4.4
Successfully installed json_pure-2.7.2
Successfully installed excon-0.111.0
Successfully installed travis-packagecloud-ruby-1.1.0
Successfully installed regstry-1.0.15
Successfully installed travis-cl-1.2.4
Successfully installed dpl-2.0.5.beta.2
7 gems installed
dpl.1
3.00sInstall deployment dependencies
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    current directory: /home/travis/.rvm/gems/ruby-3.3.5/gems/racc-1.8.1/ext/racc/cparse
/home/travis/.rvm/rubies/ruby-3.3.5/bin/ruby extconf.rb
creating Makefile
current directory: /home/travis/.rvm/gems/ruby-3.3.5/gems/racc-1.8.1/ext/racc/cparse
make DESTDIR\= sitearchdir\=./.gem.20240912-10121-9phwsw sitelibdir\=./.gem.20240912-10121-9phwsw clean
current directory: /home/travis/.rvm/gems/ruby-3.3.5/gems/racc-1.8.1/ext/racc/cparse
make DESTDIR\= sitearchdir\=./.gem.20240912-10121-9phwsw sitelibdir\=./.gem.20240912-10121-9phwsw
compiling cparse.c
gcc: error: unrecognized command line option ‘-fdeclspec’
gcc: error: unrecognized command line option ‘-Wextra-tokens’; did you mean ‘-Wextra-semi’?
gcc: error: unrecognized command line option ‘-Wdivision-by-zero’; did you mean ‘-Wdiv-by-zero’?
gcc: error: unrecognized command line option ‘-Wshorten-64-to-32’
make: *** [Makefile:248: cparse.o] Error 1
make failed, exit code 2
Gem files will remain installed in /home/travis/.rvm/gems/ruby-3.3.5/gems/racc-1.8.1 for inspection.
Results logged to /home/travis/.rvm/gems/ruby-3.3.5/extensions/x86_64-linux/3.3.0/racc-1.8.1/gem_make.out
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:51:in `block in make'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `each'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `make'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in `build_extension'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block in build_extensions'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `build_extensions'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/installer.rb:853:in `build_extensions'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:109:in `build_extensions'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/rubygems_gem_installer.rb:28:in `install'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/source/rubygems.rb:205:in `install'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:54:in `install'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:132:in `do_install'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/installer/parallel_installer.rb:123:in `block in worker_pool'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/worker.rb:62:in `apply_func'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/worker.rb:54:in `process_queue'
  /home/travis/.rvm/rubies/ruby-3.3.5/lib/ruby/3.3.0/bundler/worker.rb:90:in `block (2 levels) in create_threads'
An error occurred while installing racc (1.8.1), and Bundler cannot continue.
In Gemfile:
  nokogiri was resolved to 1.16.7, which depends on
    racc
 (Bundler::InstallError)
failed to deploy

travis.yml:

os: linux
dist: focal

language: ruby

rvm:
  - "2.7.5"

services:
  - docker
deploy:
        - provider: elasticbeanstalk
          access_key_id: ${AWS_ACCESS_KEY_ID}
          secret_access_key: ${AWS_SECRET_ACCESS_KEY}
          region: eu-west-1
          app: {our app}
          env: {our env}
          bucket: {our bucket}
          edge: true
          on:
            branch: development

Github issue link Error during installation of dpl · Issue #1287 · travis-ci/dpl · GitHub

This is an issue with Ruby 3.3.4 and 3.3.5. See e.g. this issue for a completely unrelated gem: bigdecimal install error · Issue #297 · ruby/bigdecimal · GitHub

EDIT: Actually it seems like it is an issue with RVM… gem installation failure with clang and gcc · Issue #8015 · rubygems/rubygems · GitHub

Fixed for us by using a dist: bionic

os: linux
dist: bionic

language: ruby