简体   繁体   中英

How do I open ruby file in irb?

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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