# Setting an environment variable (for libxml2)

**URL:** <https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207>\
**Category:** Ruby\
**Created:** [March 9, 2006, 8:56pm UTC](https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207 "2006-03-09T20:56:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 9, 2006, 8:56pm UTC](https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207/1 "2006-03-09T20:56:29Z")

</div>

because i plane to use XML Catalog, i have to set an environment  
variable “XML\_CATALOG\_FILES” to the path the catalogs reside.

then if i do :

ENV[‘XML\_CATALOG\_FILES’]="/path/to/catalogs"

does this env var be accessible by libxml2 and ruby-libxml ?

obviously, if i print back :  
ENV.each { |k,v| p “#{k} =\> #{v}”}

i get it.

when i say accessible from libxml2/ruby-libxml it is only when those are  
called from a ruby script…

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 10, 2006, 12:57am UTC](https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207/2 "2006-03-10T00:57:47Z")

</div>

On Fri, 2006-03-10 at 04:53 +0900, Une bÃ©vue wrote:

> because i plane to use XML Catalog, i have to set an environment  
> variable “XML\_CATALOG\_FILES” to the path the catalogs reside.
> 
> then if i do :
> 
> ENV[‘XML\_CATALOG\_FILES’]="/path/to/catalogs"
> 
> does this env var be accessible by libxml2 and ruby-libxml ?

I’m not absolutely certain, but I don’t think the change will be noticed  
by libxml2/-ruby . Some quick experiments seem to bear this out, but  
YMMV…

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 10, 2006, 1:31am UTC](https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207/3 "2006-03-10T01:31:04Z")

</div>

On Mar 9, 2006, at 2:53 PM, Une bévue wrote:

> ENV.each { |k,v| p “#{k} =\> #{v}”}
> 
> i get it.
> 
> ## when i say accessible from libxml2/ruby-libxml it is only when those are called from a ruby script…
> 
> une bévue

What you probably need to do is split your script in twain, 1 that  
sets up the environment and one that does the work, eg:

logan:/Users/logan/Projects/Ruby Experiments% cat env1.rb  
ENV[“CUSTOM\_ENV\_VAR”] = “Hello”

exec(“ruby env2.rb”)  
logan:/Users/logan/Projects/Ruby Experiments% cat env2.rb  
puts “Custom ENV var is #{ENV[“CUSTOM\_ENV\_VAR”]}”  
logan:/Users/logan/Projects/Ruby Experiments% ruby env1.rb  
Custom ENV var is Hello

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [March 10, 2006, 8:25am UTC](https://www.ruby-forum.com/t/setting-an-environment-variable-for-libxml2/79207/4 "2006-03-10T08:25:42Z")

</div>

Logan C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> logan:/Users/logan/Projects/Ruby Experiments% ruby env1.rb  
> Custom ENV var is Hello

ok, i see what u mean, i’ve done that with java to set, internaly, the  
class path…

i need somehow an app launcher to setup the ENV correctly…
