# Modifying the PATH envariable

**URL:** <https://www.ruby-forum.com/t/modifying-the-path-envariable/81741>\
**Category:** Ruby\
**Created:** [January 12, 2007, 10:59am UTC](https://www.ruby-forum.com/t/modifying-the-path-envariable/81741 "2007-01-12T10:59:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 12, 2007, 10:59am UTC](https://www.ruby-forum.com/t/modifying-the-path-envariable/81741/1 "2007-01-12T10:59:24Z")

</div>

Our app invokes some binary executables (imagine `convert image.png`).  
In order to make deployment error free, I’d like to include them in our  
source tree, and add the paths to the ENV[‘PATH’] dynamically.

Is there a cross platform way of doing this? Unix uses ‘:’ as a path  
separator, Windows uses ‘;’.

In case you’re wondering how the binaries can be cross platform.  
Imaging:  
/vendor/bin/i386-linux/  
/vendor/bin/i386-mswin32/  
require ‘rbconfig’  
add\_to\_path(‘vendor/bin/’ + Config::CONFIG[‘arch’] + ‘/’)

Not sure how to compile cross Linux binaries, though - they’re often  
dependent on the distro and even version. Is it enough to compile them  
statically linked?

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 14, 2007, 12:40am UTC](https://www.ruby-forum.com/t/modifying-the-path-envariable/81741/2 "2007-01-14T00:40:37Z")

</div>

Robert J. wrote:

> Our app invokes some binary executables (imagine `convert image.png`).  
> In order to make deployment error free, I’d like to include them in our  
> source tree, and add the paths to the ENV[‘PATH’] dynamically.
> 
> Is there a cross platform way of doing this? Unix uses ‘:’ as a path  
> separator, Windows uses ‘;’.
> 
> Not sure how to compile cross Linux binaries, though - they’re often  
> dependent on the distro and even version. Is it enough to compile them  
> statically linked?

Can anyobdy get me started with this?

---

<div class="post-metadata">

**Author:** ![robertjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e9c0ed/32.png) [@robertjames](https://www.ruby-forum.com/u/robertjames)\
**Post date:** [January 19, 2007, 4:31pm UTC](https://www.ruby-forum.com/t/modifying-the-path-envariable/81741/3 "2007-01-19T16:31:18Z")

</div>

On 1/14/07, Robert J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Robert J. wrote:
> 
> > Our app invokes some binary executables (imagine `convert image.png`).  
> > In order to make deployment error free, I’d like to include them in our  
> > source tree, and add the paths to the ENV[‘PATH’] dynamically.

If it’s in the source tree, maybe you can use full paths in the  
invocation.

> > Is there a cross platform way of doing this? Unix uses ‘:’ as a path  
> > separator, Windows uses ‘;’.

File::PATH\_SEPARATOR, [http://www.rubycentral.com/book/ref\_c\_file.html](http://www.rubycentral.com/book/ref_c_file.html)  
ENV[‘PATH’] \<\< File::PATH\_SEPARATOR \<\< ‘new.dir’

See also File::SEPARATOR and File#join
