【发布时间】:2016-07-18 18:39:04
【问题描述】:
在这里完成 Ruby 业余爱好者。在各种交互式在线编码环境中使用 Ruby 后,我想我会尝试在我的 Windows 上设置 Ruby,就像我设置 Python 一样(使用 Atom 和 Terminal-Plus)。在过去 3 小时感到沮丧和谷歌搜索答案之后,我想我会把我的问题带到这里。
使用 Python,我可以将文件 (test.py) 保存在 Atom 中,然后使用 Terminal-Plus 通过键入以下命令执行它:
py -i test.py
这将创建一个交互式 shell,我可以在其中调用存储在我的测试 Python 脚本中的任何函数。我了解到我可以使用 Ruby(对于测试文件 test.rb)做类似的事情:
ruby -r test.rb
但这会产生以下错误:
C:/Ruby21- x64/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such
file -- test.rb (LoadError)
from C:/Ruby21-x64/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
如果我使用 cmd 提示符尝试执行脚本,也会发生同样的事情。我见过类似这样的其他问题,其中该人缺少他们试图调用的关键 RubyGem,但我的 test.rb 文件实际上是:
def xyz
for i in 1..100
puts i
end
end
我只是想调用一个 Ruby 脚本并能够调用我在控制台中的脚本中存储的函数,在本例中为 xyz。
【问题讨论】:
标签: ruby terminal console atom-editor