Skip to content

require "bigdecimal" does not install BigDecimal() if it was called previously #9196

@trinistr

Description

@trinistr

Environment Information

  • jruby 10.0.3.0-SNAPSHOT (3.4.5) 2025-11-30 ffffffffff OpenJDK 64-Bit Server VM 21.0.9+10 on 21.0.9+10 +indy +jit [x86_64-linux] (master branch)
  • Linux 6.18.4-1-MANJARO #1 SMP PREEMPT_DYNAMIC Thu, 08 Jan 2026 12:46:08 +0000 x86_64 GNU/Linux

Expected Behavior

Running the following code should output 0.1e2:

jruby <<RUBY   
begin
# forgot to require "bigdecimal"
BigDecimal(10)
rescue
# oops, an error happens
end
require "bigdecimal"
puts BigDecimal(10)
RUBY

This can also be more reasonably done in an interactive irb session.

Actual Behavior

BigDecimal() doesn't get installed by require:

NoMethodError: undefined method 'BigDecimal' for main
  <main> at -:6

However, this works correctly:

jruby <<RUBY
require "bigdecimal"
puts BigDecimal(10)
RUBY
# => 0.1e2

I'm not sure if the problem is in Kernel or main, as in both cases Kernel.methods.include?(:BigDecimal) is true and self.methods.include?(:BigDecimal) is false. Testing with defined?(BigDecimal(10)) fails in the problematic case and returns method in working case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions