"-version" produced curious result; "--version" ran as expected" -- why?

Discussion in 'Ruby' started by Richard Lionheart, Jan 28, 2006.

  1. Hi All,

    I just expanded ruby-1.8.4-i386-mswin32.zip into my Utilities directory and
    added it bin subdirectory to my PATH.

    In a Command window, I entered/got:

    F:\> ruby -version

    ruby 1.8.4 (2005-12-24) [i386-mswin32]

    ruby: no such file to load -- ubygems (LoadError)



    F:\>


    Why did ruby want to load "ubygems"? BTW, I happened to notice an
    environment variable RUBYOPT set to rubygems (left over from a previous
    installation, no doubt.)

    I then recalled the options should have double hyphens, so --version didn't
    produce that spurious line.

    Any explanation? Not critical. Just curious.
    --
    TIA,
    Richard
    Richard Lionheart, Jan 28, 2006
    #1
    1. Advertising

  2. Remember that, being of UNIX lineage, ruby follows its conventions. One
    of those conventions is options vs. long-options. Long options I think
    were a GNU invention, intended to make command options (traditionally
    one letter after hyphen) more mnemonic. Long options start with double
    hyphens, and short options with one. A single double hyphen signals the
    end of options. Thus the long-option equivalent of "-v" is "--version".

    "-version" as an option is parsed as a compound of "-x" options with x
    in v,e,r,s,i,o,n; -e -i and -r require parameters, so they should parse
    the following command-line arguments as their parameters.

    My guess: RUBYOPT is additional options, and is "pasted-in" the
    command-line. So one of e,i options ate the "r" from 'rubygems' and
    then the -r option tried to load the library 'ubygems'.

    Experiment a little and you might understand exacly how the option
    parameters are used, and in what order.

    Daniel.
    Daniel Calvelo, Jan 28, 2006
    #2
    1. Advertising

  3. Hi Daniel,

    Understood! Thanks for the clear,comprehensive and timely response.

    Regards,
    Richard

    "Daniel Calvelo" <> wrote in message
    news:...
    > Remember that, being of UNIX lineage, ruby follows its conventions. One
    > of those conventions is options vs. long-options. Long options I think
    > were a GNU invention, intended to make command options (traditionally
    > one letter after hyphen) more mnemonic. Long options start with double
    > hyphens, and short options with one. A single double hyphen signals the
    > end of options. Thus the long-option equivalent of "-v" is "--version".
    >
    > "-version" as an option is parsed as a compound of "-x" options with x
    > in v,e,r,s,i,o,n; -e -i and -r require parameters, so they should parse
    > the following command-line arguments as their parameters.
    >
    > My guess: RUBYOPT is additional options, and is "pasted-in" the
    > command-line. So one of e,i options ate the "r" from 'rubygems' and
    > then the -r option tried to load the library 'ubygems'.
    >
    > Experiment a little and you might understand exacly how the option
    > parameters are used, and in what order.
    >
    > Daniel.
    >
    Richard Lionheart, Jan 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,742
    Smokey Grindel
    Dec 2, 2006
  2. yawnmoth
    Replies:
    13
    Views:
    1,358
    Andrew Thompson
    Dec 8, 2006
  3. Sue
    Replies:
    6
    Views:
    131
    Phillip Williams
    Dec 12, 2005
  4. Michael Tan
    Replies:
    32
    Views:
    928
    Ara.T.Howard
    Jul 21, 2005
  5. @
    Replies:
    3
    Views:
    108
Loading...

Share This Page