View Full Version : /usr/bin/ruby
mserms
June 17th, 2005, 08:17 AM
At the top of a ruby script I include a path to my ruby executable:
#! /usr/bin/ruby
However, on another machine, that path could be /xxx/yyy/ruby (or c:\ruby...).
Is there a way for a script to know the path for the machine that it is running on, so that an app is more portable?
rob
June 17th, 2005, 11:25 AM
This works well for that purpose:
#!/usr/bin/env ruby
This executes the Ruby interpreter as long as its properly installed no matter where it is (on UNIX/Linux that is). Not sure how to do this on Windows.
rob
June 17th, 2005, 10:11 PM
As a note about Windows, I figured out that if the .rb extension is installed properly, as it is with the Ruby installer for Windows, then running a .rb file should work, no matter what the shebang is.
mserms
June 18th, 2005, 10:30 AM
As a note about Windows, I figured out that if the .rb extension is installed properly, as it is with the Ruby installer for Windows, then running a .rb file should work, no matter what the shebang is.
Ah, cool! Your two answers combined should make it all good then - thanks!
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.