How to run ruby programs on Windows 7?

67,287

Solution 1

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.

Solution 2

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]

Solution 3

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.

Share:
67,287

Related videos on Youtube

Daniel Cook
Author by

Daniel Cook

Updated on July 18, 2020

Comments

  • Daniel Cook
    Daniel Cook almost 4 years

    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.

    • John Bachir
      John Bachir about 12 years
      Welcome 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).
    • Paul Hoffer
      Paul Hoffer about 12 years
      While Ruby isn't compiled, you can package a Ruby program for people who do not have Ruby installed, as asked here stackoverflow.com/q/4372988/366051
  • Hunter McMillen
    Hunter McMillen about 12 years
    You 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 <your_script>.rb" substituting the name of your script in. Also If you want an Eclipse like Ruby IDE, you should download Aptana, aptana.com/products/studio3/download
  • redhotvengeance
    redhotvengeance about 12 years
    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.
  • Valentin V
    Valentin V about 12 years
    Ruby is an interpreter, not a compiler, it executes scripts on the fly
  • Brian
    Brian about 12 years
    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.