kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
303 stars 23 forks source link

Classic mode app unable to start up #77

Closed kamstrup closed 6 years ago

kamstrup commented 6 years ago

When I try to start a classic mode app I get the following:

$ bundle exec ruby application.rb 
I, [2017-09-20T09:53:15.848154 #20898]  INFO -- : Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
/usr/lib/ruby/2.3.0/forwardable.rb:182:in `def_instance_delegator': undefined method `method_defined?' for main:Object (NoMethodError)
Did you mean?  method_missing
    from /usr/lib/ruby/2.3.0/forwardable.rb:157:in `block in def_instance_delegators'
    from /usr/lib/ruby/2.3.0/forwardable.rb:156:in `each'
    from /usr/lib/ruby/2.3.0/forwardable.rb:156:in `def_instance_delegators'
    from /var/lib/gems/2.3.0/gems/angelo-0.5.0/lib/angelo/main.rb:37:in `<top (required)>'
    from application.rb:1:in `require'
    from application.rb:1:in `<main>'
$ cat application.rb 
require 'angelo/main'

get "/foo" do
    "Hello world"
end

I am using angelo 0.5.0 and starting it with bundle exec ruby application.rb.

If I convert to the class based solution everything works fine.

kenichi commented 6 years ago

hello @kamstrup and thanks for trying angelo!

i can't seem to repro this problem:

$ ruby example/classic.rb 
I, [2017-09-20T13:09:54.199474 #40768]  INFO -- : Celluloid 0.17.3 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
I, [2017-09-20T13:09:54.381177 #40768]  INFO -- : Angelo 0.5.0
I, [2017-09-20T13:09:54.381219 #40768]  INFO -- : listening on 127.0.0.1:4567
I, [2017-09-20T13:09:55.748310 #40768]  INFO -- : 127.0.0.1 - - "GET / HTTP/1.1" 200 2

after reading the error you pasted, and looking at my 2.3.5 version of forwardable.rb, i'm curious if you have local changes to that file? maybe something that tries to send :method_defined? to an instance?

for reference, this is what my forwardable.rb:182 looks like:

https://github.com/ruby/ruby/blob/trunk/lib/forwardable.rb#L180-L185

kamstrup commented 6 years ago

My forwardable.rb#180-185 looks like this:

    180   def def_instance_delegator(accessor, method, ali = method)
    181     accessor = accessor.to_s
    182     if method_defined?(accessor) || private_method_defined?(accessor)
    183       accessor = "#{accessor}()"
    184     end
    185 
    186     line_no = __LINE__; str = %{
    187       def #{ali}(*args, &block)
    188         begin
    189           #{accessor}.__send__(:#{method}, *args, &block)
    190         rescue ::Exception
    191           $@.delete_if{|s| ::Forwardable::FILE_REGEXP =~ s} unless ::Forwardable::debug
    192           ::Kernel::raise
    193         end
    194       end
    195     }
    196     # If it's not a class or module, it's an instance
    197     begin
    198       module_eval(str, __FILE__, line_no)
    199     rescue
    200       instance_eval(str, __FILE__, line_no)
    201     end
    202 
    203   end

This is the stock ruby (2.3.3) install on Ubuntu 17.04, definitely not modified unless there are distropatches, which sounds unlikely. But it looks like the entire implementation of def_instance_delegator between 2.3.3 and 2.3.5 then...

kamstrup commented 6 years ago

Indeed, vanilla Ruby 2.3.3 seems to be what I have (this is the code in the v2_3_3 tag) https://github.com/ruby/ruby/blob/c91cb76f8d84b2963f6ede2ef445ad46a6104216/lib/forwardable.rb#L180-L203

kamstrup commented 6 years ago

Aha! Some git blaming later https://bugs.ruby-lang.org/issues/12478

kenichi commented 6 years ago

@kamstrup thanks for investigating! if you can upgrade ruby versions, it sounds like that will fix it. please let me know if you have any more trouble.