I’m creating a basic gem that wraps UNIX / Linux / OS X command and wanted to ensure the PATH is correctly loaded (i.e. when running under passenger for a ruby-on-rails app it have ‘/usr/bin’). Here is a simple example to illustrate what I’m trying to do (the actual example is more complicated):
module Silly
def self.tail(path)
`tail #{path}`
end
end
Should and/or can I add common folders to the PATH in ruby? If not, is it OK to directly reference /usr/bin/tail (or any other binaries in that directory) or will they be located in different directories on different systems? Thanks!
You can access environment variables with the
ENVglobal hash, soENV['PATH'] = ENV['PATH'] + ':/usr/bin'for example. It might be possible to invoke commands with/bin/sh, since that might set the path automatically.