Sublime can't handle interactive input on its own. You can either run your script through SublimeREPL or create a customized build system to open a command prompt and then run the code. Fortunately, this isn't too difficult. Create a new file in Sublime with the following contents:
{
"cmd": ["start", "cmd", "/k", "c:/ruby193/bin/ruby.exe", "$file"],
"selector": "source.ruby",
"shell": true,
"working_dir": "$file_dir"
}
Save it as Packages/User/Ruby_cmd.sublime-build
, where Packages
is the directory opened when selecting Preferences -> Browse Packages...
. Select Tools -> Build System -> Ruby_cmd
, and run your file with CtrlB.
This should work on all versions of Windows from XP on up. It is not intended for OSX or Linux, though, as they don't have the start
and cmd
programs...