From 80d0f4e2437b52db15bda7590265e96b6029a629 Mon Sep 17 00:00:00 2001 From: dearblue Date: Wed, 17 Sep 2025 22:27:36 +0900 Subject: [PATCH] Fixed wrong `MRuby::Build.current` at the top level of `mrbgem.rake` Until now, GEMS added via `gem.add_dependency` retained the last `MRuby::Build.current` from the build configuration file, which was accessible from the top level of `mrbgem.rake`. --- lib/mruby/build/load_gems.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb index e237116d8..8198abca5 100644 --- a/lib/mruby/build/load_gems.rb +++ b/lib/mruby/build/load_gems.rb @@ -32,14 +32,21 @@ module MRuby gemrake = File.join(checkout.full_gemdir, "mrbgem.rake") fail "Can't find #{gemrake}" unless File.exist?(gemrake) + current_build = MRuby::Build.current + build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current + MRuby::Build.current = build Gem.current = nil - load gemrake + begin + load gemrake + ensure + MRuby::Build.current = current_build + end return nil unless Gem.current current = Gem.current # Add it to gems current.dir = checkout.full_gemdir - current.build = self.is_a?(MRuby::Build) ? self : MRuby::Build.current + current.build = build current.build_config_initializer = block gems << current