34

How can I run a Ruby file with ST2 and see the ouput? I thought I should use the build command. But if I have this:

def foobar
  "hello world"
end

puts foobar

and then press cmd + shift + b. All I see is

[Finished in 0.1s]

In textmate I could use the cmd + r (run command) and see all the ouput from the ruby script.

I'm I missing something?

0

5 Answers 5

38

I didn't save the file. That's why it didn't work. To run a file without saving it first (like TextMate) you should try to use the Anypreter plugin.

4
  • 1
    Anypreter wasn't that good btw. Not even close to TextMate's run command.
    – vermin
    Sep 14, 2012 at 6:33
  • 1
    Yeah, Sublime Text 2 in general is nowhere near as nice as TextMate. I only use it because (1) it is cross-platform, and (2) it is rock solid in its handling of system crashes. TextMate sucks rocks when it comes to system crashes. If your system dies, all your unsaved work dies with it. Sublime Text 2 has never failed me yet when my system dies. (Which happens more often on Windows, where I can't use TextMate anyway, but it does happen on OS X often enough to make Sublime Text well worth it, the Volvo of the text editor world.)
    – iconoclast
    Dec 27, 2012 at 16:00
  • Wow, things have changed. TextMate 2 has been bullet-proof in surviving crashes for a while now (I switched back as soon as I found this out) and still (IMHO) a much nicer experience overall than any other editors. But it's still missing many valuable features, which eventually pulled me back to Sublime (3). So I've gotta solve all of Sublime's deficiencies all over again. :/
    – iconoclast
    Jun 9, 2016 at 22:09
  • have you found anything better than Anypreter? Anything that approaches TextMate's UX?
    – iconoclast
    Jun 9, 2016 at 22:10
32

I'm using windows here, but make sure you have selected the correct build system: "Tools > Build System > Ruby", then just press CTRL+B

3
  • 1
    I have Ruby selected as build system. And if I press cmd + b (OSX) I get the same result.
    – vermin
    Jul 10, 2012 at 9:54
  • @vermin The Build System of Sublime Text is intended to capture up to 4 errors, not the full output. See: docs.sublimetext.info/en/latest/file_processing/…
    – Robert K
    Aug 7, 2012 at 18:23
  • This is more convenient than the text mate.
    – Mirage
    Sep 14, 2013 at 10:50
4

For future reference, hope it helps somebody:

I came here with the same problem. (In Sublime Text 3) I followed the answers:

  • selected ruby extention (bottom right in window)
  • selected in menubar: Tools > Build System > Ruby
  • save the file with a name
  • pressed command + b

and still saw:

[Finished in 0.1s]

In the end the (stuppid) problem was: the console window was only one line big. So I only saw the last line, which is the note:

[Finished in 0.1s]

solution: make the console window bigger et voila. I couldn't find any setting for that. So in the end I did that with the mouse Screenshot Sublime Text 3 - cropped

note the cursor (and ruby extention)

2

In summary a Sublime text has an "Automatic" Build System by default (after install) and you should changed it to a ruby or whatever language you use. Save the file and press ctrl + b (on windows) - should run the output into the ST console.

1

enter control + ` (key close to number 1 in keyboard so it will open new window bottom of sublime text, where you can enter ruby code and see result), but make sure you have install ruby correctly and set your path from terminal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.