Bug #6548
closedRake doesn't ignore arguments after --
Added by rosenfeld (Rodrigo Rosenfeld Rosas) over 12 years ago. Updated about 12 years ago.
Description
I've created this issue first in GitHub before I realized that Rake is now part of stdlib:
https://github.com/jimweirich/rake/issues/115
I'll copy it here:
rake some_task -- some_arg
Raises an error after running some_task:
Don't know how to build task some_arg.
Updated by mame (Yusuke Endoh) over 12 years ago
- Status changed from Open to Assigned
- Assignee set to drbrain (Eric Hodel)
I guess rake in stdlib is just a mirror, so it should be first fixed in GitHub.
Anyway I'm assigning this to drbrain because recently he often import the latest Rake maybe from GitHub.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by drbrain (Eric Hodel) over 12 years ago
- Status changed from Assigned to Closed
- Target version changed from 1.9.3 to 2.0.0
Primary development happens on github, so I will close this issue.
I left a comment on the github issue.
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 12 years ago
It seems Jim Weirich doesn't believe this is a bug actually. I'd like to open up this for further discussion on ruby-core list.
Matz, do you have any opinion about how rake should handle "--" in arguments list?
Updated by drbrain (Eric Hodel) about 12 years ago
With all due respect to matz, the final decision should be Jim's.
Jim wrote rake and rake has supported the current behavior for many years. Please respect Jim's decision.
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 12 years ago
It is not a matter of respect. I do respect Jim's opinion, but this is how I see this.
Clearly this is not expected behavior for any script (in Unix, -- means that additional options should be ignored).
Now if rake was independent from Ruby distribution we should be done and I wouldn't arguee about this decision here.
But it is part of stdlib, and as so, I think this should be a Ruby core developers decision.
I don't think it is reasonable to break expecations of how programs should work. I respect Jim's opinion and I'm grateful for all his work, but I just think we should discuss this decision further more. After all rake is bundled with Ruby, it is not just an isolated gem.
Updated by jeremyevans0 (Jeremy Evans) about 12 years ago
rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
It is not a matter of respect. I do respect Jim's opinion, but this is how I see this.
Clearly this is not expected behavior for any script (in Unix, -- means that additional options should be ignored).
More accurately, in most unix programs, "--" denotes that everything after is treated as an argument instead of an option.
For example "fgrep -n -i foo" searches standard input for foo with -n and -i options, while "fgrep -n -- -i foo" searches for -i in foo with -n option.
What this means for rake is that "rake -- --tasks" should treat "--tasks" as a target/task instead of an option. It doesn't appear to do that ("rake -- --tasks" appears to execute the default task), which may be an issue.
Considering rake is "ruby make", there is an argument to be made that it should operate like make:
$ make -n foo
make: don't know how to make foo
$ make -- -n foo
make: don't know how to make -n
Note that the standard unix "--" behavior is for options handling only, and is unrelated to your example "rake some_task -- some_arg", which doesn't contain options.
Now if rake was independent from Ruby distribution we should be done and I wouldn't arguee about this decision here.
But it is part of stdlib, and as so, I think this should be a Ruby core developers decision.
I don't think it is reasonable to break expecations of how programs should work. I respect Jim's opinion and I'm grateful for all his work, but I just think we should discuss this decision further more. After all rake is bundled with Ruby, it is not just an isolated gem.
I agree with Eric that it should be Jim's decision, unless matz wants to fork rake.
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 12 years ago
Here is my use case. I've developed some gems for testing client-side code, including oojs. I've created an example on how to use it even for non-Ruby/Rails applications.
Then I created a task like "rake oojs:spec -- --name=shopping_cart"
https://github.com/rosenfeld/oojs_assets_enabler
In the original oojs gem, there is actually a generator for it:
https://github.com/rosenfeld/oojs
rails g oojs:spec shopping_cart
For non-Ruby projects, I'd like to be able to do something similar using rake, but I would like to be able to call it like:
rake oojs:spec -- shopping_cart
But this is not possible. What is the expected way to provide some arguments to a rake task not using options?
Updated by drbrain (Eric Hodel) about 12 years ago
Use rake task arguments:
http://rubyforge.org/pipermail/rake-devel/2007-December/000352.html
See also:
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 12 years ago
Great! Thank you so much, Eric! I'll give it a try as soon as I find some time to work on this again.
Updated by jimweirich (Jim Weirich) about 12 years ago
Actually, the post Eric refers to is a bit out of date. Look for the section "Tasks with Arguments" in the Rakefile writeup on GitHub: https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc
Updated by rosenfeld (Rodrigo Rosenfeld Rosas) about 12 years ago
Thanks for pointing me out to the documentation, Jim, but just knowing
about this feature existence was enough for me to get it working
yesterday night:
https://github.com/rosenfeld/oojs_assets_enabler/commit/a38f67278821a4d7cd1e9c7564d4afa5186c81ef
https://github.com/rosenfeld/grails-oojs/commit/cf35e3f90c1f0835828e4f8f3b116c7b1e02daaa
I'll be talking about oojs and oojspec tomorrow on Rock'n Rails so I
thought it would be better if I fixed this soon :)
http://www.rockandrails.com.br/
Thank you very much Jim and Eric for all your support. And thanks
Jeremy, not only with regards to your excelent Sequel gem which I use
everyday, but also for better explaining the expected behavior of "--"
in Unix programs :)
P.S: Sorry for posting this as an e-mail reply but Redmine was giving me
a 500 error when I tried to update the issue there.
Em 19-10-2012 00:18, jimweirich (Jim Weirich) escreveu:
Issue #6548 has been updated by jimweirich (Jim Weirich).
Actually, the post Eric refers to is a bit out of date. Look for the section "Tasks with Arguments" in the Rakefile writeup on GitHub: https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc
Bug #6548: Rake doesn't ignore arguments after --
https://bugs.ruby-lang.org/issues/6548#change-31035Author: rosenfeld (Rodrigo Rosenfeld Rosas)
Status: Closed
Priority: Normal
Assignee: drbrain (Eric Hodel)
Category: lib
Target version: 2.0.0
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]I've created this issue first in GitHub before I realized that Rake is now part of stdlib:
https://github.com/jimweirich/rake/issues/115
I'll copy it here:
rake some_task -- some_arg
Raises an error after running some_task:
Don't know how to build task some_arg.