Does anyone know how to run/compile Ruby programs on Windows 7? For example you can compile Java in Eclipse, but I can't seem to find one for Ruby.
-
4Welcome to Stack Overflow! I edited your question title to be more clear. You should accept whichever answer you think is best (click the checkmark), and vote up any other answers that were helpful for you (click the arrow above the number on the left of the answer). – John Bachir Feb 18 '12 at 18:18
-
While Ruby isn't compiled, you can package a Ruby program for people who do not have Ruby installed, as asked here http://stackoverflow.com/q/4372988/366051 – Paul Hoffer Feb 18 '12 at 21:51
5 Answers
http://rubyinstaller.org/ - "The easy way to install Ruby on Windows".
Will give you the language and execution environment - everything you should need to get started.

- 27,446
- 10
- 49
- 54
-
8You dont compile ruby programs, you just run them. Create a ruby script (i.e. it ends in '.rb'). Then at your command line type: "ruby
.rb" substituting the name of your script in. Also If you want an Eclipse like Ruby IDE, you should download Aptana, http://www.aptana.com/products/studio3/download – Hunter McMillen Feb 18 '12 at 18:08 -
Unlike Java, Ruby is an interpreted language, which means that, in general (and theory), you don't compile it. You'd execute scripts in its runtime. Theoretically, a compiler can be built for Ruby, but it isn't necessary. If you're looking to bundle up some Ruby functionality and distribute it, take a look into Ruby Gems. – redhotvengeance Feb 18 '12 at 18:08
-
Ruby is an interpreter, not a compiler, it executes scripts on the fly – Valentin V Feb 18 '12 at 18:09
-
Assuming you have added the ruby interpreter to your path, you can run scripts via: `ruby name_of_script.rb`. The scripts are compiled @ runtime. I believe that the ruby installer for windows includes DevKit which will allow you to compile ruby code with C extensions. – Brian Feb 18 '12 at 18:12
Ruby isn't compiled, but rather interpreted. You need to install Ruby using the above link given by @ilollar.
Then, if you have the source code of a program in the file some_ruby.rb
, you will execute this in cmd:
ruby some_options.rb
This is the general form of a ruby command:
ruby [ruby options] [program name] [program options]

- 34,849
- 13
- 91
- 116
Here is a free online book that will answer most of the question you have about Ruby if you are just starting out: http://ruby.learncodethehardway.org/book/
It's called "Learn Ruby the Hard Way", but don't let the name throw you off - the book is actually pretty easy to follow and doesn't assume you know anything about programming.
It will get you started writing Ruby and running programs for the first time.
Like ilollar said, the Ruby Installer is the best way to put Ruby on your Windows computer.
I'm currently running Ruby on Windows 7 writing Rails applications. You can do a lot on Windows with Ruby, however, you can't do everything. There are bundles of files that you can download that will help you write your Ruby programs - they are called Gems. Some gems will not run on Windows - The Ruby Racer and some versions of EventMachine are two that immediately come to mind.
This can be frustrating, but if it ever happens you can install a version of Linux in a virtual machine on your Windows computer so that you can use these gems without having to get a new machine.
You can also install Linux to run alongside Windows without having to reformat or mess with the partitions on your hard drive. There is a program called 'Wubi' that will install Ubuntu (a version of Linux) to run inside your Windows machine. It will actually let you pick Windows or Linux when you start your machine.
But all this is stuff to think about later on. You can certainly develop Ruby on Windows for now.

- 9,358
- 8
- 49
- 63
Also, in case you want to run just Ruby interactively, find the location where it is installed and browse to the bin subdirectory. For me this was \RailsInstaller\Ruby1.9.3\bin. In this directory there should be a file irb.bat. Double-click on it and you'll get a Ruby console session.

- 1
- 1
You can create window executables with ocra. That way you can create the app and push the app to another pc that does not have Ruby installed on it.

- 94
- 7