Reputation: 1172
Every once in a while, I fire up iTerm 2, which is using zsh, to work on tutorials. Sometimes, when I try to run my Ruby tests, they don't run. Nothing gets returned. The process never runs and I have to ctrl+C to break out of it.
Here's the command I run:
ruby -I test/unit/name_of_test.rb
This happens with all of my tests. Sometimes I just have to restart my computer. Any ideas?
I've also tried using Terminal, which is also using zsh.
I'm on OS X, using Ruby 1.9.3 and Rails 3.2.8.
Upvotes: 0
Views: 113
Reputation: 160551
This isn't really a Ruby, iTerm 2, Terminal, or zsh problem. Instead, it's not understanding how *nix OS apps handle reading from STDIN.
The problem you're seeing is that -I
specifies the $LOAD_PATH
directory. As a result, Ruby is using your path/to/script as the LOAD_PATH
variable and then hanging, waiting for input from STDIN because it didn't see a script to run.
Rather than using CNTRL+C, or restarting, use CNTRL+D. That closes the input stream, which will cause Ruby to exit since it found no commands to run.
You can test this using:
ruby -I /dev/null
at the command-line. Ruby will hang, waiting for input. Close the input and Ruby will immediately exit. Of course, if you didn't realize that's what happened, you might end up typing some interesting commands to Ruby, which won't do anything until it sees CNTRL+D, then might spit out all sorts of informative messages, but that's understandable since the input would probably be crazy-talk as far as the interpreter is concerned.
That same CNTRL+D combination is used to close input from all sorts of other *nix programs when they are reading from STDIN.
Upvotes: 2
Reputation: 1172
Doh! As I was writing this, I spotted my problem and figured I'd go ahead and provide the answer in case anyone else ever does this. I needed to adjust my command to include the word test before specifying the directory, like so:
ruby -I test test/unit/name_of_test.rb
Upvotes: 1