Get user input in Atom while running Ruby script


Ruby file: fetch.rb. It has a ‘gets.chomp’ command to get user input.

Works fine with ‘ruby ./fetch.rb’ run from terminal command line.

Ctl + Shift + B runs ruby scripts fine as long as there is no user input as above.

On the other hand ‘script-runner’ shows the terminal input and output. This requires ‘Alt + x’.

Ctl+Shift+B shows in a small window at bottom of editor script. Much nicer and succinct. Any suggestion on how to get this to work?



[SOLVED] " Cannot find module '..\build\Release\pty.node' "

There isn’t a Ctrl+Shift+B keybinding for running scripts in Atom. Is this perhaps from the script or build packages?


I am not certain. Until I installed ‘script-runner’ I used Ctrl + Shift + B and the Ruby script always ran or gave the error or gave the printed output at the bottom of the script area in the editor. Fast, simple and unobtrusive. Script-runner has a terminal-style pop up which obscures code and must be closed by clicking on the windows ‘x’ icon.

In the other version (Ctrl + Shift +B) all the output was at the bottom few lines of the screen. Both the script and the few lines in the result screen are scrollable. And nothing actually has to be closed.

Programming continues in the upper script session and many runs via the Ctrl + Shift + B sequence can be done. This just does NOT work with user input using Ruby’s ‘gets.chomp’ command assigned to a variable.

The Alt + x sequence gets really tedious and inefficient.




You need to be precise about what packages you’re using. ctrl-shift-b and the behavior you describe are found in the script package. To my knowledge, that package does not have the ability to solicit user input, so unless the maintainers add it, you’ll have to use a different solution like the script-runner package.


Thank you, DamnedScholar,

It appears to be as you describe. Script does not accept user input in Ruby. But Script-runner does.

I will stick with Script-runner when I code for user input, otherwise it will be Script.

Thank you for your prompt and clear reply.

And many thanks, too, to the Wizards of Atom for a delightful and amazing experience. Makes coding a joy.



Author of here. If you would like to provide some feedback, feel free to open an issue:

I see you mention using different keyboard short-cuts. This is currently open for discussion, some people already discussing this eg.