meltingice / flickr-store

Store arbitrary data on Flickr
MIT License
275 stars 18 forks source link

`update_dict!': undefined method `write' for File:Class (NoMethodError) #1

Open OscarGodson opened 11 years ago

OscarGodson commented 11 years ago

This looks pretty cool, but I'm getting this error:

bin $ ./flickr-authenticate
API Key: XXXXXXXXXXXXX
API Secret: XXXXXXXXXXXXX
Visit this URL in your browser: https://secure.flickr.com/services/oauth/authorize?oauth_token=72157633560816298-43c60b84122fc035&perms=delete
Paste the number given after logging in:
XXX-XXX-XXX
Authentication complete! Logged in as boozker.
Credentials saved!
{:api_key=>"XXXXXXXXXXXXX",
 :shared_secret=>"XXXXXXXXXXXXX",
 :access_token=>"XXXXXXXXXXXXX-XXXXXXXXXXXXX",
 :access_secret=>"XXXXXXXXXXXXX"}
bin $ ./flickr-store ~/Desktop/index.html
Please specify an action and file to store
bin $ ./flickr-store put ~/Desktop/index.html
/Users/oscar/Dropbox/projects/flickr-store/lib/flickr-store.rb:101:in `update_dict!': undefined method `write' for File:Class (NoMethodError)
    from /Users/oscar/Dropbox/projects/flickr-store/lib/flickr-store.rb:78:in `upload'
    from ./flickr-store:19:in `<main>'

Also, no idea why, maybe you have an idea, but I have to run these as shell scripts (./flickr-store) because even after doing gem install I get bash: flickr-authenticate: command not found.

meltingice commented 11 years ago

That's pretty weird, what version of Ruby are you running? Also, make sure your PATH is setup correctly to run and find gem executables.

OscarGodson commented 11 years ago

Actually, no idea how, but the commands are being found in BASH now. Went to bed, woke up, and all of a sudden it can find them.

The errors tho still happen. It still uploads the files, but I get the following:

Desktop $ flickr-store put jake-proj/package.json
/Users/oscar/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/flickr-store-0.0.3/lib/flickr-store.rb:101:in `update_dict!': undefined method `write' for File:Class (NoMethodError)
    from /Users/oscar/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/flickr-store-0.0.3/lib/flickr-store.rb:78:in `upload'
    from /Users/oscar/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/flickr-store-0.0.3/bin/flickr-store:19:in `<top (required)>'
    from /Users/oscar/.rbenv/versions/1.9.2-p320/bin/flickr-store:23:in `load'
    from /Users/oscar/.rbenv/versions/1.9.2-p320/bin/flickr-store:23:in `<main>'

Ruby info:

Desktop $ ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin12.2.0]
dekz commented 11 years ago

It's weird mate, File::write should be inherited by IO (http://ruby-doc.org/core-1.9.3/IO.html#method-c-write). Does this happen every time you attempt to run this?

OscarGodson commented 11 years ago

@dekz Yep. Never seen this error before :\

dekz commented 11 years ago

Oh I see it now, you're using 1.9.2 which doesn't seem to have File::write only File#write http://ruby-doc.org/core-1.9.2/IO.html#method-i-write. It should work if you update to a recent version of Ruby(1.9.3). Or we could refactor that code to open and then write.