繁体   English   中英

无法在Ruby 2.0.0中传递命令行参数

[英]Unable to pass command line arguments in Ruby 2.0.0

我刚刚在Windows 7上安装了Ruby 2.0.0(使用“rubyinstaller-2.0.0-p247-x64.exe”)。 我认为文件关联是可以的:

$> assoc .rb
.rb = rbfile

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

但是,我无法将任何参数传递给解释器。

所以,如果我运行一个简单的脚本(test.rb):

puts ARGV[0]

它什么都没有:

>test.rb test1
>

我想我应该补充一点,直到昨天我安装了Ruby 1.9.3。 我卸载了它,并安装了上面的(Ruby 2.0.0)。 一切都曾经在Ruby 1.9.3中运行良好。

请帮忙 !!

谢谢。

其他人在过去曾遇到类似 Vista和Ruby 1.9的问题 它似乎与手动修改或旧版本的卸载有关。

在Windows 7上干净安装“rubyinstaller-2.0.0-p247-x64.exe”对我来说很有用。 assocftype命令知道ruby。

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

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

我建议您通过以管理员身份启动Shell并运行ftype rbfile=assoc .rb=取消设置这些值。 如果这没有帮助(进行备份)并删除包含rbfile所有注册表项。 正确的密钥使用RubyFileRubyWFile InnoSetup脚本包含正确的注册表项。

在Windows 7中为我工作:

  • 运行regedit
  • 找到HKEY_CLASSES_ROOT \\ Applications \\ ruby​​.exe \\ shell \\ open \\ command
  • 确保“(默认)”条目说:(默认)REG_SZ“C:\\ Ruby21-x64 \\ bin \\ ruby​​.exe”“%1”%*当我选中时,我的%*丢失了。 当然,红宝石路径必须与安装红宝石的地方相匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM