我想使用 Windows 10 powershell 执行 ruby 文件。在我的 powershell 终端中,当我输入
ruby test.rb
我收到
ruby: The term 'ruby' is not recognized as the name of the cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:1
+ ruby test.rb
+Category Info :ObjectNotFound: (ruby:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
这些命令也不起作用
ruby.exe test.rb
rb.exe test.rb
我在正确的目录中。我怀疑问题与路径有关,但我还不明白路径。我一直在尝试在 Powershell 和我的初学者 IDE Visual Studio Code 中执行 .rb 文件。
谢谢
最佳答案
绝对是你的路径有问题。试试这个:
$Path = 'C:\Path\to\ruby.exe'
& $Path args
确保 ruby.exe
的根文件夹位于 $env:Path
变量中。
$env:Path -split ';'
关于ruby - 无法使用 Powershell 执行 Ruby 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47601063/