Slide 1

Slide 1 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Long journey of Ruby standard library. Hiroshi SHIBATA @hsbt 2024/05/15 RubyKaigi 2024

Slide 2

Slide 2 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Hiroshi SHIBATA https://hsbt.org @hsbt Ruby core team RubyGems/Bundler team Technical fellow at ANDPAD Self introduction

Slide 3

Slide 3 text

Copyright © 2020 Present ANDPAD Inc. This information is confidential and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential ແஅసࡌɾແஅෳ੡ͷېࢭ

Slide 4

Slide 4 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Introduction of ANDPAD

Slide 5

Slide 5 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ History of standard libraries

Slide 6

Slide 6 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ How load Ruby code from outside of Ruby core?

Slide 7

Slide 7 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Classification of Ruby core library Embedded Class • String • Time • ... Standard Library • URI • JSON • RSS • ... Ruby C extension Library • JSON • OpenSSL • ... Pure Ruby Library • URI • FileUtils • ...

Slide 8

Slide 8 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ History for rubygems and related services • 2003: Launch raa.ruby-lang.org and rubyforge.org • 2004: RubyGems is released • 2007: Ruby 1.9.0 is released with RubyGems 1.3 • 2009: Closed gems.github.com • 2009: Transition gemcutter.org and gems.rubyforge.org to rubygems.org • 2012-13: gemcutter utility has been merged into rubygems • 2013: Closed raa.ruby-lang.org • 2014: Closed rubyforge.org • 2014-: rubygems.org is canonical library repository for the Ruby language

Slide 9

Slide 9 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ History of library volume for Ruby language We bundled a lot of library at Ruby 1.8 because we don't have rubygems.org yet. Ruby 1.6 Ruby 1.8 Ruby 2.7 Ruby 3.3 Pure Ruby 63 104 65 56 C extensions 15 26 34 29

Slide 10

Slide 10 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Classification of Standard library in 2024 Embedded Class • String • Time • ... Standard Library • URI • JSON • RSS • ... Ruby C extension • RbConfig • ... Pure Ruby Library • mkmf • ... Default Gems • JSON • URI • ... Bundled Gems • Racc • RSS • ...

Slide 11

Slide 11 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ What are default and bundled gems?

Slide 12

Slide 12 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ What's Default gems • The Ruby core team released "Default gems" to the rubygems.org. • You can install standard libraries of Ruby via RubyGems. • Default gems are openssl, psych, json, etc… You can see all of default gems at https://stdgems.org/ • Rubygems have a detection method for default gems. >> require 'rss' => true >> Gem.loaded_specs["rss"].default_gem? => false >> require 'openssl' => true >> Gem.loaded_specs["openssl"].default_gem? => true

Slide 13

Slide 13 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ How develop the default gems $ bundle install $ rake test ruby/* repositories can develop bundler and rake same as your application. Default gems repository is located under the https://github.com/ruby

Slide 14

Slide 14 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ sync_default_gems.rb ruby/prism rubygems/rubygems ruby/ruby

Slide 15

Slide 15 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ What's Bundled gems • We bundled *.gem and unpacked fi les to tarball package for Bundled gems with `gems/bundled_gems` in ruby/ruby repository like this: • `make install` installed Bundled gem your box.

Slide 16

Slide 16 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Why we need to default gems and bundled gems? Security Sustainability

Slide 17

Slide 17 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ New feature of Ruby 3.3 For RubyGems/Bundler

Slide 18

Slide 18 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ The major problem for the bundled gems If you use Bundler, you need to add the bundled gems into your Gem fi le. source "https://rubygems.org" gem “rss” # You need to this because rss is bundled gems # gem "openssl" # You can load openssl without this line gem "bigdecimal" # You need to this always after Ruby 3.4 … I need to consider to transition and migration plan for this. But I have no idea yet. Maybe, I will add the some mechanism to Bundler internal to care about this.

Slide 19

Slide 19 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Warning feature of bundled gems • I added warning feature about bundled gems. • You can see how handle bundled gems like this. module Gem::BUNDLED_GEMS SINCE = { "rexml" => "3.0.0", "rss" => "3.0.0", "webrick" => "3.0.0", "matrix" => "3.1.0", "net-ftp" => "3.1.0", "net-imap" => "3.1.0", "net-pop" => "3.1.0", "net-smtp" => "3.1.0", "prime" => "3.1.0", "abbrev" => "3.4.0", "base64" => "3.4.0", "bigdecimal" => "3.4.0", "csv" => "3.4.0", "drb" => "3.4.0", "getoptlong" => "3.4.0", "mutex_m" => "3.4.0", "nkf" => "3.4.0", "observer" => "3.4.0", "racc" => "3.4.0", "resolv-replace" => "3.4.0", "rinda" => "3.4.0", "syslog" => "3.4.0", }.freeze $ cat -p Gemfile source "https://rubygems.org" gem "rss" $ bundle exec irb >> require "csv" (irb):1: warning: csv which will no longer be part of the default gems since Ruby 3.4.0. Add csv to your Gemfile or gemspec. => true

Slide 20

Slide 20 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ How extend require in your use case? We easily extend `require` like this. I only enabled this extension under the bundler. I added this to monkey patch collection of bundler. def replace_require(specs) return if [::Kernel.singleton_class, ::Kernel].any? {|klass| klass.respond_to?(:no_warning_require) } [::Kernel.singleton_class, ::Kernel].each do |kernel_class| kernel_class.send(:alias_method, :no_warning_require, :require) kernel_class.send(:define_method, :require) do |name| if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: specs) warn message, :uplevel => 1 end kernel_class.send(:no_warning_require, name) end if kernel_class == ::Kernel kernel_class.send(:private, :require) else kernel_class.send(:public, :require) end end end

Slide 21

Slide 21 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Example case require "bundler/inline" gemfile do source "https://rubygems.org" end require "mutex_m" require "rss" test_warn_bundled_gems.rb:7: warning: mutex_m was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add mutex_m to your Gemfile or gemspec. test_warn_bundled_gems.rb:8: warning: rss was loaded from the standard library, but is not part of the default gems since Ruby 3.0.0. Add rss to your Gemfile or gemspec. /Users/hsbt/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/3.3.0/ bundled_gems.rb:74:in `require': cannot load such file -- rss (LoadError) You can see these warning with this example Gemfile.

Slide 22

Slide 22 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Example case require "bundler/inline" gemfile do source "https://rubygems.org" gem "activesupport", "7.0.7.2" end require "active_support/all" /Users/hsbt/.local/share/gem/gems/activesupport-7.0.7.2/lib/ active_support/core_ext/big_decimal/conversions.rb:3: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. Also contact author of activesupport-7.0.7.2 to add bigdecimal into its gemspec. We also care dependencies from gems like rails.

Slide 23

Slide 23 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Issue with bootsnap and Zeitwerk • Bootsnap and Zeitwerk also extend `require` • We can't detect that because `caller_locations` is difference. .../lib/ruby/3.3.0+0/bundled_gems.rb:90:in `warning?' .../lib/ruby/3.3.0+0/bundler/rubygems_integration.rb:247:in `block (2 levels) in replace_require' .../gem/gems/activesupport-7.0.7.2/lib/active_support/core_ext/big_decimal/conversions.rb • I detect caller by `caller_locations` like this. .../lib/ruby/3.3.0+0/bundled_gems.rb:90:in `warning?' .../lib/ruby/3.3.0+0/bundler/rubygems_integration.rb:247:in `block (2 levels) in replace_require' .../gems/bootsnap-1.17.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'" .../gem/gems/activesupport-7.0.7.2/lib/active_support/core_ext/big_decimal/conversions.rb

Slide 24

Slide 24 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Issue with bootsnap and Zeitwerk • I and byroot, fxn fixed these issues at ruby master. • We will backport them to Ruby 3.3.2. Stay tuned 🙏 require "csv" • Bootsnap expand require path to full path. require "/Users/hsbt/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/3.3.0/csv" require "syslog" require "/Users/hsbt/.local/share/rbenv/versions/3.3.0-dev/lib/ruby/3.3.0/ arm64-darwin23/syslog"

Slide 25

Slide 25 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Future of standard libraries at Ruby 3.4 and 3.5

Slide 26

Slide 26 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Migration of the bundled gems

Slide 27

Slide 27 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Transition status of default/bundled gems We will reduce Standard Library and extract them to default and bunlded gems Ruby 2.7 Ruby 3.3 Ruby 3.4 Ruby 3.5 Standard Library 51 18 18 18 Default gems 48 67 55 45(?) Bundled gems 6 16 28 38(?)

Slide 28

Slide 28 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ How extract default gems • Drop dependencies across default gems • We need to consider C extension like bigdecimal. • After extracting bigdecimal as bundled gems, you need to compile that in any place. • Some of poeple don't have build toolchain in their prod environment...

Slide 29

Slide 29 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Other notable feature of Ruby 3.3 and RubyGems/Bundler

Slide 30

Slide 30 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ What are notable features from 2023 • Changes of Standard libraries • readline-ext is retired • racc is now bundled gems • Changes of RubyGems and Bundler • Generate checksums • You can see them with `CHECKSUMS` section into your lockfile manually. • Bugfix! 🐛 Gemfile.lock

Slide 31

Slide 31 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Introduction of RBS • `bundle gem` introduced `sig` directory for rbs • We migrate rbs files to bundled gems from rbs gem class Prime include Enumerable include Singleton (snip) def each(ubound = nil, generator = EratosthenesGenerator.new, &block) generator.upper_bound = ubound generator.each(&block) end class Prime include Singleton include Enumerable[Integer] extend Enumerable[Integer] (...) def each: (?Integer? ubound, ? PseudoPrimeGenerator generator) { (Integer) -> void } -> void | (?Integer? ubound, ? PseudoPrimeGenerator generator) -> PseudoPrimeGenerator

Slide 32

Slide 32 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Cross-compilation Problem

Slide 33

Slide 33 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ What's happend in RubyGems with C extension? RubyGems 3.4 and 3.5 * GEM_HOME/extensions/arm64-darwin-23/3.2.0-static/bigdecimal-3.1.6/bigdecimal.bundle * GEM_HOME/gems/bigdecimal-3.1.6/lib/bigdecimal.bundle < RubyGems 3.4 * GEM_HOME/gems/bigdecimal-3.1.6/ext/bigdecimal/bigdecimal.bundle RubyGems will install C extension into the following directories. RubyGems added extension and lib directories to require_paths both. This means we can avoid to install C extension to under lib directory. >> Gem.loaded_specs["bigdecimal"].require_paths => ["/Users/hsbt/.local/share/gem/extensions/arm64-darwin-23/3.3.0-static/bigdecimal-3.1.6", "lib"]

Slide 34

Slide 34 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ We considered namespace feature with RubyGems and Bundler I already make it with opt-in configuration for RubyGems 3.6. You can skip to install C extension Under the `lib` directory like this. gem: "--no-document" :install_extension_in_lib: false gemsrc_use_ghq: true

Slide 35

Slide 35 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Separate vendored libraries with namespace

Slide 36

Slide 36 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Activation issue of default gems We still have a activation issue with RubyGems and the default gems like `json`. How handle this problem? You have already activated timeout 0.3.1, but your Gemfile requires timeout 0.3.2. Since timeout is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports timeout as a default gem.

Slide 37

Slide 37 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ How handle activation problem? Rewrite default gems written by C extension to pure ruby code. Vendoring approach when RubyGems uses only pure ruby libraries like URI.

Slide 38

Slide 38 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ We considered namespace feature with RubyGems and Bundler tagomoris-san proposed namespace feature for package system of Ruby. It may help our activation problem. Ex. RubyGems and Bundler will use JSON under only their namespace. You can activate any version of JSON on your application.

Slide 39

Slide 39 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Wrap up

Slide 40

Slide 40 text

$PQZSJHIU˜1SFTFOU"/%1"%*OD5IJTJOGPSNBUJPOJTDPOGJEFOUJBMBOEXBTQSFQBSFECZ"/%1"%*ODGPSUIFVTFPGPVSDMJFOU*UJTOPUUPCFSFMJFEPOCZBOESEQBSUZ1SPQSJFUBSZ$POGJEFOUJBMແஅసࡌɾແஅෳ੡ͷېࢭ Conclusion • I talked about... • History of Libraries, RubyGems, Bundler and their feature. • How handle default gems and bundled gems in Ruby 3.3. • What happens Ruby 3.4 and 3.5 < Ruby is a programmer's best friend