title: set search path for exec spawn and popen in ruby
body: <p>Suppose there is executable /path/to/hello. I want to do this</p>
  
  <pre><code>set-search-path "/path/to:/another/path:/usr/bin:/bin"
  IO.popen({},[["hello","argv0"],"argv1"])
  </code></pre>
  
  <p>I know we can specify full path for "hello", but prefer to see a solution with search path if possible.</p>
  
  <p>Also setting the path prior to invocation of ruby interpreter is not what I'm looking for.</p>
  
  <p>I guess this involves setting the environment of ruby itself, thus maybe a wrapper around the setenv(3) c library function can do.</p>
  
  <p>Please also point out what if I use popen the other way, passing a string to the shell.</p>
  
  <p>I'm currently running ruby2.1.</p>