0

The rvm command lets you tell it what environment you want to use and pass a block to it to invoke a script or something (for a one-time run of the command) e.g.:

rvm 1.9.2-p290@whatever-gemset do ruby my-script.rb

However, if the script accepts command line arguments as well and you try to pass them script at invocation, rvm complains. Does anyone know if rvm has syntax to support/allow this?

e.g.:

rvm 1.9.2-p290@whatever-gemset do ruby my-script.rb -p
ERROR: Unrecognized command line argument(s): '-p' ( see: 'rvm usage' )
3
  • 2
    Does putting your command in quotes work? do "ruby my-script.rb -p" Commented Jun 6, 2012 at 16:01
  • I did. No such luck unfortunately. Commented Jun 6, 2012 at 16:30
  • Actually, it does for me... However, a coworker of mine is getting some weird behavior when trying to do it that way which may just be specific to his environment. In any case, you've answered my question and for that I thank you. Commented Jun 6, 2012 at 16:53

1 Answer 1

1

To avoid rvm trying to parse those parameters as arguments to rvm itself, put them in quotes to pass them as a single argument:

rvm 1.9.2-p290@whatever-gemset do "ruby my-script.rb -p"

The only reason this would fail is if some kind of shell-expansion is being done before this command is actually executed which is non-standard behavior.

Sign up to request clarification or add additional context in comments.

3 Comments

also it would be good idea to open a bug report github.com/wayneeseguin/rvm/issues - the arguments after do should not be parsed.
A naive argument parser will always make this mistake. Even Ruby's option parsers will fall for this unless you use the -- separator to manually turn off argument parsing. The way to fix this is to pre-process the command-line arguments and only feed in a subset to your option parser. It does sound like a bug, though.
in rvm do should behave like --, there are few rvm sub-commands that when it just stop processing and pass arguments to sub-command handler, i do not know why it did not worked for do, but with the bug report i will have a note to check it later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.