Ruby STDIN.gets return nil directly while running

2019-03-01 11:28发布

问题:

I wrote a simple ruby code:

puts gets
puts STDIN.gets

It runs ok in the console, but when I run it with Command B in Sublime Text2 it printed nothing and doesn't prompt for input; It seems that gets return nil directly.

I checked the file Ruby.sublime-build:

{
    "cmd": ["/Users/yangbin/.rvm/bin/rvm-auto-ruby", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.ruby"
}

And ran the command /Users/yangbin/.rvm/bin/rvm-auto-ruby test.rb, I was prompted to input something and it printed ok.

yangbin$ /Users/yangbin/.rvm/bin/rvm-auto-ruby test.rb
hello
hello

What's wrong with the configuration with ruby in Sublime Text2 ?