Skip to content

Upgrade mruby from 3.0.0 to 3.4.0#149

Merged
k0kubun merged 10 commits intomasterfrom
mruby-3-4-0
Apr 4, 2026
Merged

Upgrade mruby from 3.0.0 to 3.4.0#149
k0kubun merged 10 commits intomasterfrom
mruby-3-4-0

Conversation

@k0kubun
Copy link
Copy Markdown
Member

@k0kubun k0kubun commented Apr 4, 2026

Summary

Closes #119, closes #125

k0kubun added 10 commits April 3, 2026 17:21
- Remove mruby-print dependency (merged into mruby core in 3.4.0)
- Remove mruby/mruby#5318 patch (fixed upstream since 3.1.0)
- Delete build_config.rb.lock for regeneration
mruby 3.4.0 includes mruby-dir as a core gem. The external
iij/mruby-dir fails to compile due to missing error.h header.
- Use **opts for keyword argument forwarding instead of hash-as-last-arg
  pattern, since mruby 3.4.0 separates positional hashes from kwargs
- Add explicit Node#merge! to avoid method_missing delegation issues
  with private method visibility enforcement in mruby 3.4.0
- Override String#shellescape and Array#shelljoin to call public
  module_function names instead of private singleton aliases
module_function in mruby 3.4.0 doesn't create public singleton methods,
making Shellwords.shellescape and Shellwords.shelljoin inaccessible.
Inline the implementation into String#shellescape and Array#shelljoin,
and use instance method calls instead of Shellwords module methods.
- Use ::File.open instead of File.open in ResourceExecutor::File
  to avoid resolving to the inner File class + Kernel#open (private)
- Redefine Open3.capture3/capture2/capture2e as explicit public
  class methods since module_function creates private singleton
  methods in mruby 3.4.0
- Define Shellwords.shellescape/shelljoin as explicit public singleton
  methods (def self.xxx) so external gems like specinfra can call them
- Change RecipeLoader#initialize to use keyword arguments instead of
  a positional hash, fixing hash-to-kwargs conversion in mruby 3.4.0
In mruby 3.4.0, the [] operator in precompiled bytecode dispatches
directly to C-level Hash#[] via OP_GETIDX, bypassing Ruby method
overrides including Hashie::Mash's alias_method :[], :custom_reader.
This means symbol keys like attributes[:action] hit Hash#[] without
Mash's key conversion (symbol -> string), returning nil.

Fix by using string keys when accessing Hashie::Mash from precompiled
code in resource/base.rb, resource_context.rb, and resource_executor.
- Use string keys in Node#[] when accessing @mash to avoid the
  OP_GETIDX optimization that bypasses Hashie::Mash's key conversion
- Make Kernel#` accessible by redefining it in compat.rb, since
  module_function makes it private in mruby 3.4.0
mruby 3.4.0 changed Hash#to_s format. Hashie::Mash objects now render
as #<Hashie::Mash key=val> instead of {"key"=>"val"}. Update regexes
to match both old and new formats.
@k0kubun k0kubun marked this pull request as ready for review April 4, 2026 03:04
@k0kubun k0kubun merged commit 6dad12a into master Apr 4, 2026
17 of 18 checks passed
@k0kubun k0kubun deleted the mruby-3-4-0 branch April 4, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant