简体   繁体   English

Ruby上的LoadError

[英]LoadError on Ruby

I just installed Atom text editor and Ruby, typed a single line of ruby code in the Atom text editor; 我刚刚安装了Atom文本编辑器和Ruby,在Atom文本编辑器中键入了一行ruby代码; puts "Hello world" but the Atom Runner returns with an error message; 将“Hello world”放入,但Atom Runner返回错误消息;

ruby: No such file or directory -- C:/Users/OKaro/Desktop/Ruby/example.rb (LoadError). ruby:没有这样的文件或目录 - C:/Users/OKaro/Desktop/Ruby/example.rb(LoadError)。

How can I fix this? 我怎样才能解决这个问题?

Am using a Windows 10 PC, running ruby 2.5.3p105 我使用的是Windows 10 PC,运行ruby 2.5.3p105
Atom : 1.35.1 原子:1.35.1
Electron: 2.0.18 电子:2.0.18

I have tried running the ruby code with command prompt and it works perfectly. 我尝试使用命令提示符运行ruby代码,它运行正常。 giving me the desired Hello world output 给我想要的Hello world输出

Figuring out what your current working directory is for your running script. 找出当前工作目录对于正在运行的脚本的作用。

Add this line at your code: 在您的代码中添加以下行:

puts Dir.pwd

This code print's the path of your file. 此代码打印是文件的路径。

Then check if your atom-runner is configured to accept ruby scripts on config.cson file (Atom -> Config) like atom-runner documentation says to do 然后检查你的atom-runner是否配置为接受config.cson文件(Atom - > Config)上的ruby脚本,就像atom-runner文档说要做的那样

Atom-runner Atom的亚军

"*":
....
'runner':
    'scopes':
      'coffee': 'coffee'
      'js': 'node'
      'ruby': 'ruby'

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

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