Closed whoisstan closed 12 years ago
It would be more helpful to have your Gemfile.lock
than the output of bundle install
.
True! Here it is. Thank you!
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.3)
actionpack (= 3.2.3)
mail (~> 2.4.4)
actionpack (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.3)
activesupport (= 3.2.3)
builder (~> 3.0.0)
activerecord (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.3)
activemodel (= 3.2.3)
activesupport (= 3.2.3)
activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
apn_on_rails (0.5.1)
actionpack
activerecord
configatron
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.3)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.5)
ffi (~> 1.0, >= 1.0.6)
configatron (2.9.1)
yamler (>= 0.1.0)
daemons (1.1.9)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
faraday (0.8.4)
multipart-post (~> 1.1)
ffi (1.1.5)
foreigner (1.2.1)
activerecord (>= 3.0.0)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.5)
libwebsocket (0.1.5)
addressable
macaddr (1.6.1)
systemu (~> 2.5.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.19)
multi_json (1.3.6)
multipart-post (1.1.5)
newrelic_rpm (3.4.2.1)
nokogiri (1.5.5)
pg (0.12.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-protection (1.2.0)
rack
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.3)
actionmailer (= 3.2.3)
actionpack (= 3.2.3)
activerecord (= 3.2.3)
activeresource (= 3.2.3)
activesupport (= 3.2.3)
bundler (~> 1.0)
railties (= 3.2.3)
railties (3.2.3)
actionpack (= 3.2.3)
activesupport (= 3.2.3)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
redis (3.0.2)
redis-namespace (1.2.1)
redis (~> 3.0.0)
resque (1.23.0)
multi_json (~> 1.0)
redis-namespace (~> 1.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (2.0.0)
redis (>= 2.0.1)
resque (>= 1.20.0)
rufus-scheduler
rspec (2.10.0)
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
rspec-rails (2.10.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.10.0)
rubyzip (0.9.9)
rufus-scheduler (2.0.17)
tzinfo (>= 0.3.23)
selenium-webdriver (2.25.0)
childprocess (>= 0.2.5)
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
simple_oauth (0.1.9)
sinatra (1.3.3)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
systemu (2.5.2)
thin (1.5.0)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
twitter (4.1.0)
faraday (~> 0.8)
multi_json (~> 1.3)
simple_oauth (~> 0.1.6)
tzinfo (0.3.33)
uuid (2.3.5)
macaddr (~> 1.0)
vegas (0.1.11)
rack (>= 1.0.0)
xpath (0.1.4)
nokogiri (~> 1.3)
yajl-ruby (1.1.0)
yaml_db (0.2.3)
yamler (0.1.0)
PLATFORMS
ruby
DEPENDENCIES
apn_on_rails
bcrypt-ruby (= 3.0.1)
capybara (= 1.1.2)
foreigner
newrelic_rpm
pg (= 0.12.2)
rails (= 3.2.3)
resque
resque-scheduler
rspec-rails (= 2.10.0)
thin
twitter
uuid (~> 2.3.5)
yajl-ruby
yaml_db
yamler
Thanks.
My hunch is that the hash keys aren't being properly converted to symbols when they're converted from JSON object to Ruby hash but I'm not sure why that would be happening. I can't reproduce the problem on my end, even with your Gemfile.lock
.
This sounds like a very likely ruby issue.
Is there a debug/verbose mode in the gem that would allow me to confirm that?
I highly doubt it's a bug in Ruby.
If you want to debug the issue, try adding a breakpoint after line 34 of lib/twitter/identity.rb
(after super
). Then inspect the value of @attrs
. If you can show me the value of that instance variable at that point in the execution, that will help me understand the issue better.
I highly doubt it's a bug in Ruby. I meant that a symbol vs string problem is not untypical in the ruby eco system
This looks promising. (When I add attrs.symbolize_keys! before super it all works just fine).
{"entities"=>{"urls"=>[], "user_mentions"=>[], "hashtags"=>[]}, "in_reply_to_user_id_str"=>nil, "place"=>nil, "retweeted"=>false, "in_reply_to_screen_name"=>nil, "in_reply_to_status_id"=>nil, "truncated"=>false, "user"=>{"id"=>768201997, "time_zone"=>"Atlantic Time (Canada)", "location"=>"", "profile_background_image_url"=>" http://a0.twimg.com/images/themes/theme1/bg.png", "statuses_count"=>29, "id_str"=>"768201997", "entities"=>{"description"=>{"urls"=>[]}}, "profile_link_color"=>"0084B4", "geo_enabled"=>false, "profile_image_url_https"=>" https://si0.twimg.com/profile_images/2692748469/e40452e9627d11c82820ec77f1eb3b1a_normal.png", "listed_count"=>0, "profile_image_url"=>" http://a0.twimg.com/profile_images/2692748469/e40452e9627d11c82820ec77f1eb3b1a_normal.png", "utc_offset"=>-14400, "profile_use_background_image"=>false, "name"=>"stanCharacter1", "follow_request_sent"=>false, "profile_text_color"=>"333333", "lang"=>"en", "screen_name"=>"stanCharacter1", "protected"=>false, "followers_count"=>0, "profile_sidebar_border_color"=>"fff", "default_profile_image"=>false, "friends_count"=>5, "description"=>"", "favourites_count"=>0, "profile_background_tile"=>false, "following"=>false, "profile_sidebar_fill_color"=>"DDEEF6", "url"=>nil, "is_translator"=>false, "profile_background_image_url_https"=>" https://si0.twimg.com/images/themes/theme1/bg.png", "created_at"=>"Sun Aug 19 20:34:38 +0000 2012", "verified"=>false, "notifications"=>false, "profile_background_color"=>"000000", "default_profile"=>false, "contributors_enabled"=>false}, "in_reply_to_user_id"=>nil, "contributors"=>nil, "coordinates"=>nil, "retweet_count"=>0, "favorited"=>false, "created_at"=>"Tue Oct 09 04:33:00 +0000 2012", "geo"=>nil, "source"=>"<a href=\"http://www.placeholder.com\" rel=\"nofollow\">stanCharacter1", "id_str"=>"255526252067299328", "id"=>255526252067299328, "in_reply_to_status_id_str"=>nil, "text"=>"hi1122"}
On Mon, Oct 8, 2012 at 11:45 PM, Erik Michaels-Ober < notifications@github.com> wrote:
I highly doubt it's a bug in Ruby.
If you want to debug the issue, try adding a breakpoint after line 34 of lib/twitter/identity.rb (after super). Then inspect the value of @attrs. If you can show me the value of that instance variable at that point in the execution, that will help me understand the issue better.
— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9248115.
"Local color. Soak it up" Virginia Vidaura
Looks like my hunch was correct. So the question is: what's happening on line 13 of lib/twitter/response/parse_json.rb
? It should be calling:
MultiJson.load(body, :symbolize_keys => true)
…which should be returning a hash with symbols as keys. Can you verify that line is being executed but setting another breakpoint in there? I'd also be curious to see the output of MultiJson.engine
at that point in the execution.
line 13 of lib/twitter/response/parse_json.rb MultiJson.load(body, :symbolize_keys => true)
So here is what goes in (dup) {"errors":[{"code":187,"message":"Status is a duplicate"}]}
and what comes out out MultiJson.load {"errors"=>[{"code"=>187, "message"=>"Status is a duplicate"}]}
In my Gemfile.lock are 2 MultiJson gem's (one via activerecord), this is the problem right? An old gem that doesn't support the option?
On Tue, Oct 9, 2012 at 12:59 AM, Erik Michaels-Ober < notifications@github.com> wrote:
Looks like my hunch was correct. So the question is what's happening on line 13 of lib/twitter/response/parse_json.rb. It should be calling:
MultiJson.load(body, :symbolize_keys => true)
…which should be returning a hash with symbols as keys. Can you verify that line is being executed but setting another breakpoint in there? I'd also be curious to see the output of MultiJson.engine at that point in the execution.
— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9248999.
"Local color. Soak it up" Virginia Vidaura
I'm not sure that's the problem, since your Gemfile.lock
says you're using the latest version of multi_json
. Not sure why that's not working. Can you try the following in your rails console
?
MultiJson.load('{"s":1}', :symbolize_keys => true)
{"s"=>1}
strings!
(need to sign off for now (east coast)) - talk soon and thanks soooo much for the great help!
On Tue, Oct 9, 2012 at 1:27 AM, Erik Michaels-Ober <notifications@github.com
wrote:
I'm not sure that's the problem, since your Gemfile.lock says you're using the latest version of multi_json. Not sure why that's not working. Can you try the following in your rails console?
MultiJson.load('{"s":1}', :symbolize_keys => true)
— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9249412.
"Local color. Soak it up" Virginia Vidaura
anything else you want me to try? let me know.
What's the output of MultiJson.engine
in rails console
?
1.9.3p194 :007 > MultiJson.engine => MultiJson::Adapters::JsonGem
On Tue, Oct 9, 2012 at 12:39 PM, Erik Michaels-Ober < notifications@github.com> wrote:
What's the output of MultiJson.engine in your Rails console?
— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9268810.
"Local color. Soak it up" Virginia Vidaura
This seems like a very serious bug in multi_json
, which I also work on. I'm surprised that this is the first I've heard of it, considering the current version of multi_json
was released in May and has been downloaded over 2.5 million times.
I'm still unable to reproduce this problem. Could you please answer a few more questions:
What's the result of the following in rails console
:
::JSON.parse('{"s":1}', :symbolize_names => true)
What's the result of the following in rails console
:
MultiJson.engine = :json_pure
MultiJson.load('{"s":1}', :symbolize_keys => true)
MultiJson.engine = :yajl
MultiJson.load('{"s":1}', :symbolize_keys => true)
MultiJson.engine = :oj
MultiJson.load('{"s":1}', :symbolize_keys => true)
Note: You'll need to add json_pure
, yajl-ruby
, and oj
, to your Gemfile
and run bundle install
before doing 3 above.
I'm having this issue as well, and I'm not using rails. The only json engine I'm using is regular old json.
irb(main):009:0> require 'json'
=> true
irb(main):010:0> ::JSON.parse('{"s":1}', :symbolize_names => true)
=> {"s"=>1}
irb(main):011:0> MultiJson.load('{"s":1}', :symbolize_keys => true)
=> {"s"=>1}
$ ruby rtwit.rb
/usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/identity.rb:35:in initialize': argument must have an :id key (ArgumentError) from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/base.rb:69:in
new'
from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/base.rb:69:in fetch_or_new' from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/base.rb:59:in
from_response'
from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/api.rb:2351:in object_from_response' from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/api.rb:1898:in
update'
from /usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter.rb:23:in method_missing' from rtwit.rb:42:in
What version of Ruby are you running? Do you have the json
gem installed? If so, what version?
Sorry for the delay, busy times. Thanks for your support!
- What version of Ruby are you running?
ruby-1.9.3-p194
- What's the result of the following in rails console: ::JSON.parse('{"s":1}', :symbolize_names => true)
1.9.3p194 :001 > ::JSON.parse('{"s":1}', :symbolize_names => true) => {:s=>1}
What's the result of the following in rails console:
MultiJson.engine = :json_pure MultiJson.load('{"s":1}', :symbolize_keys => true) MultiJson.engine = :yajl MultiJson.load('{"s":1}', :symbolize_keys => true) MultiJson.engine = :oj MultiJson.load('{"s":1}', :symbolize_keys => true)
1.9.3p194 :002 > MultiJson.engine = :json_pure => :json_pure 1.9.3p194 :003 > MultiJson.load('{"s":1}', :symbolize_keys => true) => {:s=>1} 1.9.3p194 :004 > MultiJson.engine = :yajl => :yajl 1.9.3p194 :005 > MultiJson.load('{"s":1}', :symbolize_keys => true) => {:s=>1} 1.9.3p194 :006 > MultiJson.engine = :oj => :oj 1.9.3p194 :007 > MultiJson.load('{"s":1}', :symbolize_keys => true) => {:s=>1}
I used this as a workaround
module Twitter class Identity < Twitter::Base
def initialize(attrs={})
attrs.symbolize_keys!
super
raise ArgumentError, "argument must have an :id key" unless id
end
end end
On Mon, Oct 15, 2012 at 2:20 PM, Steven E. Newton notifications@github.comwrote:
I'm having this issue as well, and I'm not using rails. The only json engine I'm using is regular old json.
irb(main):009:0> require 'json' => true irb(main):010:0> ::JSON.parse('{"s":1}', :symbolize_names => true) => {"s"=>1} irb(main):011:0> MultiJson.load('{"s":1}', :symbolize_keys => true) => {"s"=>1}
— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9455680.
"Local color. Soak it up" Virginia Vidaura
For me I have: $ ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]
I don't have the json gem installed, just the json libraries that came with my ruby install. I might try
whoisstan's workaround resulted in this error for me.
/usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/identity.rb:34:in `initialize': undefined method `symbolize_keys!' for #<Hash:0x95d220c> (NoMethodError)
@snewtonj Ruby 1.9.1 is not a supported ruby version. Please upgrade to either 1.9.2 or 1.9.3 (or downgrade to 1.8.7) and let me know whether the problem persists.
yes, forgot that you are not using rails. its a rails extension, should be able to use the source here.
http://as.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Keys.html
def symbolize_keys 23: inject({}) do |options, (key, value)| 24: options[(key.to_sym rescue key) || key] = value 25: options 26: end 27: end
# File lib/active_support/core_ext/hash/keys.rb, line 30
30: def symbolize_keys! 31: self.replace(self.symbolize_keys) 32: end
On Mon, Oct 15, 2012 at 4:21 PM, Steven E. Newton notifications@github.comwrote:
whoisstan's workaround resulted in this error for me.
/usr/lib/ruby/gems/1.9.1/gems/twitter-4.1.0/lib/twitter/identity.rb:34:in
initialize': undefined method
symbolize_keys!' for #Hash:0x95d220c (NoMethodError)— Reply to this email directly or view it on GitHubhttps://github.com/sferik/twitter/issues/317#issuecomment-9460075.
"Local color. Soak it up" Virginia Vidaura
Thanks for the tips guys. It was enough of a pain to get ruby, gem, the OS, and this library to all come agree on a configuration they allowed that will at least run, if with an error. I think I'll leave it where it is and worry about the error later. It's good to see that Ruby and Debian/Ubuntu continue to not be able to agree on whether the OS or just the Ruby interpreter is in charge of dependency management and that apt and gem are still conducting trench warfare against each other.
I am using 4.1.0 and am sending an update via:
Twitter.update(message)
and am getting this error here:
Whats interesting is that the tweet actually appears on the timeline of the associated app. I am not sure whats going wrong. Also interestingly enough I an similar app (slightly different bundle) I use the same twitter configuration and its all working fine. I get the same error when I invoke 'Twitter.home_timeline'
Here is my bundle config if that helps:
Any help is greatly appreciated!! Stan