Forum: Ruby setting an environment variable (for libxml2)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C8da03a9f69be8910fa9b16b4db969ed?d=identicon&s=25 unknown (Guest)
on 2006-03-09 20:56
(Received via mailing list)
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...
A9b6a93b860020caf9d2d1d58c32478f?d=identicon&s=25 Ross Bamford (Guest)
on 2006-03-10 00:57
(Received via mailing list)
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...
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-03-10 01:31
(Received via mailing list)
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
C8da03a9f69be8910fa9b16b4db969ed?d=identicon&s=25 unknown (Guest)
on 2006-03-10 08:25
(Received via mailing list)
Logan Capaldo <logancapaldo@gmail.com> 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...
This topic is locked and can not be replied to.