Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The command "ruby" does nothing on my Mac

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:

  1. I have some bash customizations, so I tried disabling them, but that didn't help.
  2. I installed a new copy of Ruby 1.8.7 using MacPorts, but that one had the same problem.
  3. I tried quitting and restarting the Terminal application.

Some other information that might be useful:

  • I'm trying to run the version of Ruby that comes with Snow Leopard.
  • I have installed Apple's developer tools.
  • Other interpreters (Python, Io, etc.) work fine.

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.

like image 291
Tom S. Avatar asked Dec 14 '09 05:12

Tom S.


People also ask

What is Ruby command in Mac?

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).

Does Ruby work on Mac?

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.


1 Answers

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.

like image 160
khelll Avatar answered Oct 11 '22 06:10

khelll