'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)
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Michele Zampiccoli |