如何在IRB中打开Ruby文件?
我目前正在使用AWS Cloud 9。我想运行代码,但是当我使用Ruby命令打开IRB中的Ruby文件时,它有时可以正常工作,或者在下面给我提供了错误消息。
2.6.3 :001 > ruby directory.rb
Traceback (most recent call last):
4: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/irb:23:in `<main>'
3: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/irb:23:in `load'
2: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
1: from (irb):1
NameError (undefined local variable or method `directory' for main:Object)
I'm currently using AWS cloud 9. I want to run my code but when I use the ruby command to open up my ruby file in irb it sometimes works or it gives me the error message below.
2.6.3 :001 > ruby directory.rb
Traceback (most recent call last):
4: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/irb:23:in `<main>'
3: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/irb:23:in `load'
2: from /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
1: from (irb):1
NameError (undefined local variable or method `directory' for main:Object)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就个人而言,我只是将.RB文件拖放到CMD窗口中,然后按Enter。您有什么理由要使用IRB吗?
如果您将ATOM用作脚本编辑器,则可以安装脚本软件包直接在应用程序中运行代码! (file-&gt;设置 - &gt; packages - &gt;脚本)
态
Personally, I just drag and drop my .rb file into the cmd window and then press enter. Do you have any reason to want to use the irb?
If you use Atom as a script editor you can install the script package to run your code directly in the app! (File -> Settings -> Packages -> script)
Atom - script