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

R

Richard Lionheart

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.
 
D

Daniel Calvelo

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.
 
R

Richard Lionheart

Hi Daniel,

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

Regards,
Richard
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top