windows 如何从 Windows7 Powershell 执行 Ruby 脚本和 irb?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6750867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I execute Ruby scripts and irb from Windows7 Powershell?
提问by agente_secreto
I used the Windows Ruby Installer, and all I can do is run ruby from the normal command line with a bundled shortcut named "Command line with ruby".
我使用了 Windows Ruby 安装程序,我所能做的就是从普通命令行运行 ruby,并带有一个名为“Command line with ruby”的捆绑快捷方式。
Windows 7 Powershell is not bad as a replacement for bash, so I would like to be able to execute Ruby, irb, gem etc from it. At the very least executing scripts...
Windows 7 Powershell 作为 bash 的替代品还不错,所以我希望能够从中执行 Ruby、irb、gem 等。至少执行脚本......
I've read that this is possible, how?
我读到这是可能的,如何?
采纳答案by Will Gorman
Is the directory that Windows Ruby Installer installed to (like C:\Ruby192\bin) on your path? I can't recall if it should add that automatically on install but I've not had any issues running irb or scripts from powershell. You can check if it's on your path by running the following from a powershell session:
Windows Ruby 安装程序安装到的目录(如 C:\Ruby192\bin)是否在您的路径上?我不记得它是否应该在安装时自动添加,但我在从 powershell 运行 irb 或脚本时没有遇到任何问题。您可以通过从 powershell 会话运行以下命令来检查它是否在您的路径上:
$env:path
回答by RussianJohnResig
I've made it like this change directory to the place, where Ruby is installed(in my case this is C:\Ruby193\bin)
我已经把这个目录更改为安装 Ruby 的地方(在我的例子中是 C:\Ruby193\bin)
C:\Users\admin>cd C:\Ruby193\bin
and there simply typed irb and pressed enter:
然后简单地输入 irb 并按回车键:
C:\Ruby193\bin>irb
irb(main):001:0> 1+4
=> 5
irb(main):002:0>