Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Windows7 Powershell执行Ruby脚本和irb?_Ruby_Windows - Fatal编程技术网

如何从Windows7 Powershell执行Ruby脚本和irb?

如何从Windows7 Powershell执行Ruby脚本和irb?,ruby,windows,Ruby,Windows,我使用了WindowsRuby安装程序,我所能做的就是从普通命令行运行Ruby,并附带一个名为“commandlinewithRuby”的快捷方式 Windows7 Powershell作为bash的替代品还不错,所以我希望能够从中执行Ruby、irb、gem等。至少在执行脚本时 我已经读到这是可能的,怎么可能?Windows Ruby Installer安装到的目录(如C:\Ruby192\bin)在您的路径上吗?我不记得它是否应该在安装时自动添加,但我在运行irb或powershell脚本时

我使用了WindowsRuby安装程序,我所能做的就是从普通命令行运行Ruby,并附带一个名为“commandlinewithRuby”的快捷方式

Windows7 Powershell作为bash的替代品还不错,所以我希望能够从中执行Ruby、irb、gem等。至少在执行脚本时


我已经读到这是可能的,怎么可能?

Windows Ruby Installer安装到的目录(如C:\Ruby192\bin)在您的路径上吗?我不记得它是否应该在安装时自动添加,但我在运行irb或powershell脚本时没有遇到任何问题。您可以通过从powershell会话运行以下命令来检查它是否在您的路径上:

$env:path
我是这样做的 将目录更改为安装Ruby的位置(在我的例子中是C:\Ruby193\bin)

然后简单地键入irb并按enter键:

C:\Ruby193\bin>irb
irb(main):001:0> 1+4
=> 5
irb(main):002:0>

你说它在我的路上是什么意思?是的,这就是它安装到的目录,这意味着PATH环境变量。要设置路径变量,请单击开始,键入“环境”,然后单击“编辑帐户的环境变量”
C:\Ruby193\bin>irb
irb(main):001:0> 1+4
=> 5
irb(main):002:0>