ruby-on-railsdockerubuntu-20.04mastodon

Ubuntu 20.04 Ruby on Rails bundle update fails to install multiple gems


When I run bundle update on my mastodon folder, I get the following errors

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/administrator/mastodon/vendor/bundle/ruby/3.0.0/gems/racc-1.6.2/ext/racc/cparse
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230311-33651-izdwgu.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /home/administrator/mastodon/vendor/bundle/ruby/3.0.0/gems/racc-1.6.2 for inspection.
Results logged to
/home/administrator/mastodon/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/racc-1.6.2/gem_make.out

[TRIMMED]

An error occurred while installing racc (1.6.2), and Bundler cannot continue.

In Gemfile:
  rails-settings-cached was resolved to 0.7.2, which depends on
    rails was resolved to 6.1.7.2, which depends on
      actioncable was resolved to 6.1.7.2, which depends on
        actionpack was resolved to 6.1.7.2, which depends on
          actionview was resolved to 6.1.7.2, which depends on
            rails-dom-testing was resolved to 2.0.3, which depends on
              nokogiri was resolved to 1.14.2, which depends on
                racc


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/administrator/mastodon/vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.8/ext/nio4r
/usr/bin/ruby3.0 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230311-33651-c3y8u9.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /home/administrator/mastodon/vendor/bundle/ruby/3.0.0/gems/nio4r-2.5.8 for
inspection.
Results logged to
/home/administrator/mastodon/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/nio4r-2.5.8/gem_make.out

[TRIMMED]

An error occurred while installing nio4r (2.5.8), and Bundler cannot continue.

In Gemfile:
  rails-settings-cached was resolved to 0.7.2, which depends on
    rails was resolved to 6.1.7.2, which depends on
      actioncable was resolved to 6.1.7.2, which depends on
        nio4r

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

[TRIMMED]

An error occurred while installing websocket-driver (0.7.5), and Bundler cannot continue.

In Gemfile:
  rails-settings-cached was resolved to 0.7.2, which depends on
    rails was resolved to 6.1.7.2, which depends on
      actioncable was resolved to 6.1.7.2, which depends on
        websocket-driver


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.[trimmed
An error occurred while installing date (3.3.3), and Bundler cannot continue.

In Gemfile:
  rails-settings-cached was resolved to 0.7.2, which depends on
    rails was resolved to 6.1.7.2, which depends on
      actionmailbox was resolved to 6.1.7.2, which depends on
        mail was resolved to 2.8.1, which depends on
          net-imap was resolved to 0.3.4, which depends on
            date


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

An error occurred while installing bcrypt (3.1.18), debug_inspector (1.1.0), blurhash (0.1.7), you get the idea.

For the sake of sanity I am stopping here.

administrator@[REDACTED]:~/mastodon$ gem update --system
ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.

I also get an error on login saying

$rvm_path (/usr/share/rvm) does not exist

This occurred after I had tried using RVM to get these gems installed and kept meeting various errors and tried to uninstall it in favor of rbenv. If you could solve these errors, I would be most thankful.

For full disclosure: This server is running an instance of Mastodon within docker containers, and I want to perform the post-update database migrations, but I cannot get them to work.

Things I have tried to make the bundle update succeed:


Solution

  • I've seen that mkmf.rb error before and usually it means installing an apt-package, rather than a gem. Have you tried: sudo apt-get install ruby-dev ?