I can't get the Ruby interpreter to run on either of my Macs (one MacBook and one MacBook Pro, both running Snow Leopard). When I run it, by typing ruby
in Terminal, nothing happens. It just sits there. I can kill it by pressing Ctrl+C
, but that's it. I know the Ruby process is running, since I can see it in Activity Monitor, and running ruby --version
works fine.
I have tried the following, all to no avail:
Some other information that might be useful:
I spent a while tonight searching for this problem online, but haven't found any discussion of it. I'm at a loss for what could be causing it, so any help anybody can provide would be greatly appreciated.
MacOS comes with a “system Ruby” pre-installed. If you see /usr/bin/ruby when you use the which command, it is the pre-installed macOS system Ruby. It's a bad idea to use the Mac system, Ruby, for developing Ruby applications (it's fine to use it for running utility scripts).
ruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby. ruby-build can also be used as a standalone program without rbenv. It is available for macOS, Linux, and other UNIX-like operating systems.
Ruby command itself will just behave the way you said, either provide it with script file or use the -e option:
ruby -e ' puts "hello world" '
However I suspect that you want the IRB(interactive ruby). Run irb
in your shell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With