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:
- I have some bash customizations, so I tried disabling them, but that didn't help.
- I installed a new copy of Ruby 1.8.7 using MacPorts, but that one had the same problem.
- 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.
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.
What are you trying to do, exactly? The ruby
command expects input, in most cases a file that contains Ruby code that you want it to run. In that case you have to specify the name of the file:
> ruby my_ruby_file.rb
If instead you want to run the interactive Ruby shell, i.e. the REPL console that you can type Ruby code into and have it executed each time you press enter, the command you want is irb
.
精彩评论