thekompanee / fuubar

The instafailing RSpec progress bar formatter
http://jeffkreeftmeijer.com/2010/fuubar-the-instafailing-rspec-progress-bar-formatter/
MIT License
954 stars 65 forks source link

NameError: uninitialized constant Delegator #92

Closed tobymurray-nanometrics closed 8 years ago

tobymurray-nanometrics commented 8 years ago

Can't run RSpec with latest (2.1.0) Fuubar.

Environment

Windows 10 jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 +jit [mswin32-x86_64] Using RSpec release 3.5.0 which has rspec-core 3.5.1 (rspec --version yields 3.5.1)

λ gem list rspec
*** LOCAL GEMS ***
rspec (3.5.0, 3.4.0)
rspec-core (3.5.1, 3.4.4)
rspec-expectations (3.5.0, 3.4.0)
rspec-html-matchers (0.8.0, 0.7.3, 0.7.2)
rspec-mocks (3.5.0, 3.4.1)
rspec-rails (3.5.1, 3.4.2)
rspec-support (3.5.0, 3.4.1)
rspec_junit_formatter (0.2.3)

Fuubar 2.0.0

λ gem list fuubar
*** LOCAL GEMS ***
fuubar (2.0.0)

λ rspec spec
<snip>
Randomized with seed 2994
 0/1506 |>                                                     |  ETA: ??:??:??
<snip>

Spec run completes as expected

Fuubar 2.1.0

λ gem list fuubar
*** LOCAL GEMS ***
fuubar (2.1.0)

λ rspec spec
NameError: uninitialized constant Delegator
     const_missing at org/jruby/RubyModule.java:3309
    <class:Fuubar> at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/fuubar-2.1.0/lib/fuubar/output.rb:2
             <top> at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/fuubar-2.1.0/lib/fuubar/output.rb:1
           require at org/jruby/RubyKernel.java:944
           require at C:/tools/jruby/9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
             <top> at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/fuubar-2.1.0/lib/fuubar.rb:1
           require at org/jruby/RubyKernel.java:944
           require at C:/tools/jruby/9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:133
            (root) at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/fuubar-2.1.0/lib/fuubar.rb:4
            (root) at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/formatters.rb:1
  custom_formatter at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/formatters.rb:222
    find_formatter at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/formatters.rb:171
      block in add at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/formatters.rb:141
     add_formatter at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/configuration.rb:828
             <top> at D:/git/products/athena/athena/spec/spec_helper.rb:65
           require at org/jruby/RubyKernel.java:944
           require at C:/tools/jruby/9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
             <top> at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core.rb:97
           require at org/jruby/RubyKernel.java:944
           require at C:/tools/jruby/9.1.2.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:55
             <top> at D:/git/products/athena/athena/spec/spec_helper.rb:19
              load at org/jruby/RubyKernel.java:962
   block in (root) at D:/git/products/athena/athena/spec/rails_helper.rb:1
              each at org/jruby/RubyArray.java:1593
            (root) at D:/git/products/athena/athena/spec/rails_helper.rb:17
            (root) at D:/git/products/athena/athena/spec/controllers/amplitudes_controller_spec.rb:1
            (root) at D:/git/products/athena/athena/spec/controllers/amplitudes_controller_spec.rb:1
            (root) at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/configuration.rb:1
   load_spec_files at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/configuration.rb:1435
             <top> at C:/tools/jruby/9.1.2.0/lib/ruby/gems/shared/gems/rspec-core-3.5.1/lib/rspec/core/configuration.rb:1433
              load at org/jruby/RubyKernel.java:962
             <top> at C:\tools\jruby\9.1.2.0\bin\rspec:22
jfelchner commented 8 years ago

@tobymurray-nanometrics I was getting this sporadically but can't repro. Can you help me track it down? Delegator should be a built-in Ruby lib class: http://ruby-doc.org/stdlib-2.3.0/libdoc/delegate/rdoc/Delegator.html

fuubar:/ ⁙ irb
irb(main):001:0> ::Delegator
Delegator < BasicObject
tobymurray-nanometrics commented 8 years ago

Hmm... JRuby bug?

λ C:\tools\ruby\23-x64\bin\irb.cmd
irb(main):001:0> ::Delegator
=> Delegator
λ irb
irb(main):001:0> ::Delegator
NameError: uninitialized constant Delegator
        from org/jruby/RubyModule.java:3309:in `const_missing'
        from (irb):1:in `<eval>'
        from org/jruby/RubyKernel.java:983:in `eval'
        from org/jruby/RubyKernel.java:1290:in `loop'
        from org/jruby/RubyKernel.java:1103:in `catch'
        from org/jruby/RubyKernel.java:1103:in `catch'
        from C:/tools/jruby/9.1.2.0/bin/jirb:13:in `<top>'
jfelchner commented 8 years ago

It also looks like it fails in Ruby 2.0.0 despite this

https://travis-ci.org/thekompanee/fuubar/jobs/144316979

Curious to know what the JRuby team says.

tobymurray-nanometrics commented 8 years ago

Same behavior in JRuby 1.7.25 (Ruby 1.9.3), 9.0.5.0 (Ruby 2.2), and 9.1.1.0 (Ruby 2.3). Safe to say whatever is not working is beyond me.

enebo commented 8 years ago

@tobymurray-nanometrics @jfelchner I will posit this is not a JRuby bug based on some observations. On win7 when I run with MRI 2.2 I have the same problem as JRuby. On MacOS, Delegator is defined on both JRuby and MRI 2.3. So this leads me to believe something during bootstrapping of MRI/JRuby loads delegate.rb on MacOS but it does not on Windows.

Now I notice someone can see Delegator show up in 2.3 on Windows...but in my opinion no one can count on delegate.rb being loaded as it is a stdlib file and not a core library (unless this changed for 2.3?). To me, based on the 2.2 on MRI not loading delegator either the only solution would be for this library to explicitly load delgate.rb.

Does this seem reasonable? I hate saying it is not our bug but unless someone points out that delegate was moved to be a core class I think this is just happy circumstance that it loads on most platforms.

enebo commented 8 years ago

Ok confirmed this is a bootstrapping thing on windows. You should not rely on this as it is just by circumstance that rubygems is loading it:

mri23 --disable-gems -ve 'p ::Delegator'
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
-e:1:in `<main>': uninitialized constant Delegator (NameError)
enebo commented 8 years ago

oh sorry to fix this you should put:

require 'delegate'

at top of file which uses Delegator.

jfelchner commented 8 years ago

@enebo lemme give that a shot. Thank you! :)

jfelchner commented 8 years ago

@tobymurray-nanometrics 2.1.1 comin in hot :fire: Lemme know if it fixes it for you.

tobymurray-nanometrics commented 8 years ago

Holy cow @jfelchner, best progress bar I've seen all day. Works out of box with JRuby 9.1.2.0 on Windows. Thanks so much for taking care of this, we'll continue to make use of it. Also thanks to @enebo, very nice of you to take time to troubleshoot this despite it not really being a JRuby issue.

github-actions[bot] commented 3 years ago

This issue has been closed automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.