[MacRuby] #1262: Rack error calling [] in Faraday via the Octokit gem
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.11 Component: MacRuby | Keywords: github, octokit, rack, hubcap ------------------------------+--------------------------------------------- I'm getting the following error running this simple script in MacRuby 0.10: {{{ require 'rubygems' require 'octokit' puts Octokit.user('sferik') }}} {{{ /Users/erik/.rvm/gems/macruby-0.10/gems/rack-1.2.2/lib/rack/utils.rb:in `[]:': undefined method `[]' for nil:NilClass (NoMethodError) from /Users/erik/.rvm/gems/macruby-0.10/gems/faraday-0.6.1/lib/faraday/utils.rb:22:in `[]:' from /Users/erik/.rvm/gems/macruby-0.10/gems/faraday-0.6.1/lib/faraday/request/url_encoded.rb:18:in `match_content_type:' from /Users/erik/get_user.rb:4:in `<main>' }}} I've tried using rack 1.3.0.beta instead of 1.2.2 but I get the same error. This script works as expected on MRI 1.9.1p378 and 1.9.2p180 (also on MRI 1.8.7p334, JRuby 1.6.1, and Rubinius 1.2.3). In addition to the error. Simply requiring octokit (line 2) is extremely slow. On my machine with a 2.8 GHz Intel Core 2 Duo processor, running just the first two lines of the script takes 2 minutes and 20 seconds! I would love to be able to use the Octokit gem in the next release of MacRuby. Please let me know if there's anything I can do to help debug this issue. -- Ticket URL: <http://www.macruby.org/trac/ticket/1262> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubca , 0.11-blockerp ------------------------------+--------------------------------------------- Changes (by lsansonetti@…): * keywords: github, octokit, rack, hubcap => github, octokit, rack, hubca , 0.11-blockerp * milestone: MacRuby 0.11 => Comment: Adding 0.11-blocker keyword. -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:2> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Changes (by lsansonetti@…): * keywords: github, octokit, rack, hubca , 0.11-blockerp => github, octokit, rack, hubcap, 0.11-blocker -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:3> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by watson1978@…): in rack/utils.rb, HeaderHash's @names was initialized with https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L343 [[BR]] but, when HeaderHash#[] was invoked, @names seems to be nil. test script works if change the https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L359-361 as following. {{{ def [](k) + @names ||= {} super(k) || super(@names[k.downcase]) end }}} when suppress the JIT optimization as following (using VM_OPT_LEVEL=0), you can load more faster. {{{ $ time VM_OPT_LEVEL=0 macruby 1262-test_octokit.rb 2>&1 > /dev/null VM_OPT_LEVEL=0 macruby 1262-test_octokit.rb 2>&1 > /dev/null 6.43s user 0.36s system 98% cpu 6.879 total }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:4> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by watson1978@…): When invoked Hash#dup, does not copy instance variable. {{{ #!ruby require 'rubygems' require 'rack/utils' include Rack::Utils h = HeaderHash.new h.instance_eval{ p @names } h2 = h.dup h2.instance_eval{ p @names } }}} {{{ $ ruby19 t.rb {} {} $ macruby t.rb {} nil }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:5> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by watson1978@…): The similar problems occur other than Hash. {{{ #!ruby class MyArray < Array def initialize @names = "foo" end end a1 = MyArray.new a1.instance_eval{ p @names } a2 = a1.dup a2.instance_eval{ p @names } }}} {{{ $ ruby19 ~/tmp/ttt.rb "foo" "foo" $ DYLD_LIBRARY_PATH=. ./macruby ~/tmp/ttt.rb "foo" nil }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:6> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by eloy.de.enige@…): The problem is that classes like Array and Hash have their own #dup implementation which don't copy the dynamically defined ivars. For instance, with the following naive patch, the last Array example works: https://gist.github.com/1078981 -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:7> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by eloy.de.enige@…): Btw, a one line reduction: {{{ 1:% ./miniruby -e 'h = {}; h.instance_variable_set(:@answer, 42); p h.instance_variable_get(:@answer); p h.dup.instance_variable_get(:@answer)' 42 nil % ruby19 -e 'h = {}; h.instance_variable_set(:@answer, 42); p h.instance_variable_get(:@answer); p h.dup.instance_variable_get(:@answer)' 42 42 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:8> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by eloy.de.enige@…): Updated the gist to cover Hash in the naive patch as well. {{{ % ./miniruby -e 'h = {}; h.instance_variable_set(:@answer, 42); p h.instance_variable_get(:@answer); p h.dup.instance_variable_get(:@answer)' 42 42 % ./miniruby -e 'a = []; a.instance_variable_set(:@answer, 42); p a.instance_variable_get(:@answer); p a.dup.instance_variable_get(:@answer)' 42 42 }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:9> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ------------------------------+--------------------------------------------- Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: github, octokit, rack, hubcap, 0.11-blocker ------------------------------+--------------------------------------------- Comment(by watson1978@…): init_copy invoke String#initialize_copy at `rb_vm_call(dest, selInitializeCopy, 1, &obj);'. [[BR]] Same data is copied with rstr_copy() and String#initialize_copy. [[BR]] So, I think that rstr_copy is unnecessary, and I rewrote alloy's patch. https://gist.github.com/1210522/ -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:10> MacRuby <http://macruby.org/>
#1262: Rack error calling [] in Faraday via the Octokit gem ---------------------------------------------------------+------------------ Reporter: sferik@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: major | Milestone: MacRuby 0.11 Component: MacRuby | Resolution: fixed Keywords: github, octokit, rack, hubcap, 0.11-blocker | ---------------------------------------------------------+------------------ Changes (by watson1978@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.11 Comment: Fixed with https://github.com/MacRuby/MacRuby/commit/19514ab3772bb743960deaaf18d57dc721... -- Ticket URL: <http://www.macruby.org/trac/ticket/1262#comment:11> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby