mwunsch / tumblr

Command line interface and Ruby client for the Tumblr API (v2)
MIT License
282 stars 43 forks source link

Odd error message for tumblr pipe #29

Closed rrthomas closed 11 years ago

rrthomas commented 11 years ago

The error "tumblr pipe requires at least 0 argument", as well as popping up in situations where I haven't even asked for "tumblr pipe", is both ungrammatical and confusing: I gave it 0 arguments, so why is it complaining?

kristianfreeman commented 11 years ago

@rrthomas - can you give me a command or situation to replicate the error?

rrthomas commented 11 years ago

Sure, see issue #21.

kristianfreeman commented 11 years ago

@rrthomas – sounds like there's a doozy of problems going on. My first suggestion: do a clean install of Ruby (if you can, use rvm and grab a 1.9 build) and then do gem install tumblr-rb. I've done this on my machine and haven't had any problems. Building this gem from the git repo is probably more work than needed – there aren't any outstanding changes AFAIK since some changes of mine that @mwunsch added to the gem a couple months ago. You should just be able to do gem install, which will take care of putting it in the proper place for you to just run tumblr at the command-line.

If you've done this already, apologies, just trying to get a sense of what part of the process is fouled up for you. Thanks!

rrthomas commented 11 years ago

Thanks very much for offering to look into my other issue; I've added a comment there (issue #21).

rrthomas commented 11 years ago

By the way, my latest comment on issue #21 also illustrates this issue, as you can see a situation in which the bogus and ungrammatical error is produced.

mwunsch commented 11 years ago

@rrthomas Should we merge these two issues?

One is the very odd thing of getting tumblr pipe requires at least 0 argument when not calling tumblr pipe. That's totally strange.

If you're getting that error when calling tumblr pipe, remember that tumblr pipe DOES require an argument, in the form of STDIN.

I agree that the error message is obtuse, and is a remnant of the Thor backend of the command line interface. I can work on a patch to fix that error messaging.

rrthomas commented 11 years ago

I don't think these issues should be merged: one is a problem with installing the gem, and the other is a confusing error message.

The reason I get the tumblr pipe error when I'm not calling tumblr pipe is that "pipe" is the default command, so this means that I typed "tumblr version" but the command-parsing code is not being told about the "version" argument.

tumblr pipe does require stdin, but that's not an argument; please don't confuse the terminology.

mwunsch commented 11 years ago

When you run gem list, what versions of Thor and tumblr-rb do you see listed?

rrthomas commented 11 years ago

thor (0.16.0, 0.15.3)

The first is the one that's been installed by "gem install tumblr-rb", while the second is that installed by Ubuntu. Note:

$ which thor
/home/rrt/.gem/ruby/1.9.1/bin/thor
mwunsch commented 11 years ago

Are you using zsh?

rrthomas commented 11 years ago

No, bash.

mwunsch commented 11 years ago

Kind of stuck. My guess is this is some buggy behavior originating from Thor, but I want to make sure I can reproduce.

Do me a favor and run an irb session and require rubygems (irb -rubygems). In the session, print out Gem::VERSION. Run require 'tumblr' and run puts $:. Paste the contents of the session here so I can see precisely what's on your Ruby Load Path.

rrthomas commented 11 years ago
$ irb -rubygems
irb(main):001:0> Gem::VERSION
=> "1.8.23"
irb(main):002:0> require 'tumblr'
=> true
irb(main):003:0> puts $:
/usr/share/rubygems-integration/1.9.1/gems/rack-1.4.1/lib
/home/rrt/.gem/ruby/1.9.1/gems/addressable-2.3.3/lib
/home/rrt/.gem/ruby/1.9.1/gems/promise-0.3.0/lib
/home/rrt/.gem/ruby/1.9.1/gems/simple_oauth-0.1.9/lib
/usr/share/rubygems-integration/1.9.1/gems/multi_json-1.3.6/lib
/home/rrt/.gem/ruby/1.9.1/gems/weary-1.1.2/lib
/usr/share/rubygems-integration/1.9.1/gems/tilt-1.3.3/lib
/usr/share/rubygems-integration/1.9.1/gems/sinatra-1.3.2/lib
/home/rrt/.gem/ruby/1.9.1/gems/thor-0.16.0/lib
/home/rrt/.gem/ruby/1.9.1/gems/tumblr-rb-2.0.0/lib
/usr/local/lib/site_ruby/1.9.1
/usr/local/lib/site_ruby/1.9.1/x86_64-linux
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/1.9.1
/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/1.9.1
/usr/lib/ruby/1.9.1/x86_64-linux
=> nil

Thanks very much for persisting with this!

mwunsch commented 11 years ago

Can't figure this one out. I'm going to attempt to summon @sferik working on Thor.

Seems that between your arguments in bash and Thor's argument parsing something is going wrong or I've misunderstood how Thor works.

sferik commented 11 years ago

I just released Thor 0.18.0. Can you try upgrading and let me know what error you get, if any?

rrthomas commented 11 years ago

When I run "gem install tumblr-rb" it still installs Thor 0.16.0. Do I just wait a while? Or what?

mwunsch commented 11 years ago

@rrthomas I've just pushed to master w/ an updated gemspec that declares the new Thor dependency.

I am unable to reproduce this issue, but can you try building from source using the rake install method and see what occurs?

rrthomas commented 11 years ago

This changes things a bit:

$ rake install
tumblr-rb 2.0.1.snapshot built to pkg/tumblr-rb-2.0.1.snapshot.gem
tumblr-rb (2.0.1.snapshot) installed
$ tumblr version
ERROR: tumblr pipe was called with arguments ["version"]
Usage: "tumblr pipe".
mwunsch commented 11 years ago

@sferik Looks like what's happening here is that my Thor subclass has a default_task that is somehow swallowing up the other arguments/task names. I've heard of similar things happening with zsh globbing, but @rrthomas is using bash in Ubuntu.

I'm consistently unable to reproduce, and can only reproduce by doing something like:

$ echo 'version' | xargs tumblr pipe
rrthomas commented 11 years ago

I think I can help with what's special about my setup, your comment above jogged my memory, and SORRY! for not remembering this earlier: I have an alias set:

alias tumblr='tumblr --host=foo.tumblr.com'

If I remove that, it works fine. However, it's not obvious from the documentation that I did anything wrong, and the error message is still confusing.

rrthomas commented 11 years ago

(I'll use TUMBLRHOST as mentioned in issue #30.)

mwunsch commented 11 years ago

4924def should prevent this kind of thing in the future. So rather than getting an error when passing arguments to tumblr pipe, instead tumblr help will always be invoked.

It seems like a Thor design decision to say that option arguments should always come after the task name.

rrthomas commented 11 years ago

Thanks again for persevering with this, and sorry I didn't catch my own configuration oddity earlier.

sferik commented 11 years ago

It looks like the gem is locked to ~> 0.16.0.

If you clone the repo, update that dependency, and point your code at the clone in your Gemfile:

gem 'thor', :path => '/path/to/your/clone/of/tumblr'

Then:

bundle update tumblr