Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to pass command line arguments in Ruby 2.0.0

Tags:

windows

ruby

I just installed Ruby 2.0.0 on Windows 7 (using "rubyinstaller-2.0.0-p247-x64.exe"). I think the File associations are OK:

$> assoc .rb
.rb = rbfile

$> ftype rbfile
rbfile="C:\Ruby200-x64\bin\ruby.exe" "%1" %*

However, I cannot pass any arguments to the interpreter.

So if I run a simple script (test.rb):

puts ARGV[0]

it gives nothing:

>test.rb test1
>

I guess I should add that I had Ruby 1.9.3 installed till yesterday. I uninstalled it, and installed the above (Ruby 2.0.0). Everything used to work fine in Ruby 1.9.3.

Please help !!

Thanks.

like image 900
user2566225 Avatar asked Jul 09 '13 21:07

user2566225


2 Answers

Other people had similar problems with Vista and Ruby 1.9 in the past. It seemed to be related to manual modifications or broken uninstalls of old versions.

A clean install of "rubyinstaller-2.0.0-p247-x64.exe" on Windows 7 works for me. The assoc and ftype commands do not know about ruby.

> assoc .rb
File association not found for extension .rb

> ftype rbfile
File type 'rbfile' not found or no open command associated with it.

I'd suggest you unset these values by starting a Shell as Administrator and running ftype rbfile= and assoc .rb=. If this doesn't help (make a backup and) delete all registry keys containing rbfile. The correct keys use RubyFile or RubyWFile. The InnoSetup Script contains the correct registry entries.

like image 169
kunysch Avatar answered Sep 18 '22 16:09

kunysch


Worked for me in Windows 7:

  • Run regedit
  • Find HKEY_CLASSES_ROOT\Applications\ruby.exe\shell\open\command
  • Make sure the "(default)" entry says: (Default) REG_SZ "C:\Ruby21-x64\bin\ruby.exe" "%1" %* When I checked, the %* was missing in mine. Of course, the ruby path must match where your ruby is installed.
like image 37
LambKabobWithFeta Avatar answered Sep 19 '22 16:09

LambKabobWithFeta