I just spent three hours last night debugging a Ruby program only to figure out that the problem is a bug in Vista. I was trying to pass a command line argument to a program that just wasn't working. I assumed that I was trying to read the arguments incorrectly but it turned out that Vista just wasn't passing the arguments to the program.
Failing Vista Ruby File Association: testruby.rb value1 value2 This fails as the command line arguments value1 and value2 are never passed to the program testruby.rb (or just testruby).
Working Vista File Association: ruby testruby.rb value1 value2 Calling the ruby onterpreter directly worked showing that it was the Vista File Association manager causing the problem.
Known problem - not so quick a fix A quick Google search shows that this is a known Vista problem with pretty much everything that uses file associations and arguments. The fix, after some trial and error, was to change the registry keys. The fixes found via Google only worked after I started regedit and then did a search for 'ruby.exe' - the location of 'ruby.exe' in the HKEYCLASSESROOTApplicationsruby entry may be new with Ruby 1.9.1.
HKEYCLASSESROOTApplicationsrubyshellopencommanddefault contains the value "C:Ruby19binruby.exe" "%1"change this to "C:Ruby19binruby.exe" "%1" %*
After about another hour of trial and error, the above change is the only one that seems to work - other recommendations to change HKEYCLASSESROOTrbfileshelleditcommanddefault and HKEYCLASSESROOTrbfileshellopencommanddefault did not work (with Ruby 1.9.1).