ruby-erb is part of standard library so ruby package should depends on it

Why is ruby-erb not required by the ruby package? erb is a default gem (see https://stdgems.org/) so it is officially part of the ruby language. One can use require "irb" in his code without putting erb in it's gemspec or Gemfile. So because ruby-erb is not installed by default when installing ruby, many packages will fail erb is missing. At it's part of the standard library it's never declared as a dependency so you won't see it when packaging a tool that requires it.

For example when I tried to package a Ruby tool:

Description:

I had some PKGBUILD with:


makedepends=('git')
depends=('ruby' 'ruby-bundler')

install="$pkgname.install"

package() {

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ruby bin/$pkgname "\$@"
EOF

}

And $pkgname.install with:

post_install() {
  set -e

  bundle config build.nokogiri --use-system-libraries
  bundle config set --local path 'vendor/bundle'
  bundle config set --local without development lint docs
  bundle install
}

The PKGBUILD is building and installing correctly. But whenever I call /usr/bin/$pkgname (wrapper that executes exec bundle exec ruby bin/$pkgname), I encounter the following error:

<internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require': cannot load such file -- erb (LoadError)
Did you mean?  drb
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/vendor/bundle/ruby/3.2.0/gems/gli-2.21.5/lib/gli/commands/help.rb:1:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/vendor/bundle/ruby/3.2.0/gems/gli-2.21.5/lib/gli.rb:19:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/lib/adassault/cli/dns/duzdu/baseaction.rb:6:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/lib/adassault/cli/dns/duzdu/add.rb:3:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/lib/adassault/cli/dns/duzdu.rb:4:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/lib/adassault/cli/dns.rb:3:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from /usr/share/adassault/lib/adassault/cli.rb:4:in `<top (required)>'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from <internal:/usr/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
        from bin/ada:7:in `<main>'

But if I just add ruby-erb as dependency, it works.

-depends=('ruby' 'ruby-bundler')
+depends=('ruby' 'ruby-bundler' 'ruby-erb')

It's because a dependency gli is using erb and of course neither their gemspec nor their Gemfile is listing erb as a dependency, as expected, as erb is part of the standard library.

You can see on the official API documentation that erb is part of ruby

Steps to reproduce:

  1. echo "test" > test.txt
  2. Write the below PKGBUILD into PKGBUILD
  3. Build and install it with makepkg
  4. irb
  5. irb(main):001:0> require 'irb'
pkgname=test-erb
pkgver=0.0.1
pkgrel=1
pkgdesc='test'
arch=('any')
license=('MIT')
depends=('ruby' 'ruby-irb')
url='any'
source=("test.txt")
sha512sums=('SKIP')

package() {
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -Dm 644 test.txt "$pkgdir/usr/share/$pkgname/test"
}

Solution

As all Default gems and Bundled gems (so that are part of ruby standard library) that have a separate package on ArchLinux as dependency on the ruby package.