Forum: Ruby How do you run a .rb file in mac?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dark L. (Guest)
on 2007-01-27 08:21
Hello. I created a ruby program in Smultron, but I couldn't figure out
how to run it on a mac. Should I download anything to execute it? I
thought Macs had ruby pre -installed.  Thanks.
Nathan S. (Guest)
on 2007-01-27 09:04
(Received via mailing list)
On 1/27/07, Dark L. <removed_email_address@domain.invalid> wrote:
>
> Hello. I created a ruby program in Smultron, but I couldn't figure out
> how to run it on a mac. Should I download anything to execute it? I
> thought Macs had ruby pre -installed.  Thanks.
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Open /Applications/Utilities/Terminal.app and type: ruby file.rb

You could also type irb to get an interactive console.

Nate
Dark L. (Guest)
on 2007-01-27 10:37
Nathan S. wrote:

>>
>>
> Open /Applications/Utilities/Terminal.app and type: ruby file.rb
>
> You could also type irb to get an interactive console.
>
> Nate

Thanks a lot, Nate. It worked. :)
Damian T. (Guest)
on 2007-01-27 10:51
(Received via mailing list)
Good day!

On Jan 27, 2007, at 10:03, Nathan S. wrote:

> Open /Applications/Utilities/Terminal.app and type: ruby file.rb
>
> You could also type irb to get an interactive console.
>
> Nate

You can also add the following line at the very beginning of your ruby
script:

#!/usr/bin/env ruby

and then run the following command in the Terminal.app:

chmod u+x /path/to/your/file.rb

Then you'll be able to invoke the file by its name.

By the way, ruby that comes with OS X is a bit outdated, so it will be
not a bad option to install a fresh version. The simplest approach is
to use MacPorts.

Your sincerely,
Damian/Three-eyed Fish
This topic is locked and can not be replied to.