Setting Windows Environment Variables

Hi all!

I’m another Ruby noob and wondered if any of you can help me with my
problem.

I’ve have been tasked with writing some rake files to automate parts of
our project and to begin I’m trying to automate the setup of the build
machine. The first task is to set the environment variables.

Can this be done in Ruby without using system("%PATH% =
%PATH%;c:\ruby\bin") etc.?

Thanks in advance!!! ( :

Regards

Gem


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


On 8/14/06, Cameron, Gemma (UK) [email protected] wrote:

Hi all!

I’m another Ruby noob and wondered if any of you can help me with my problem.

I’ve have been tasked with writing some rake files to automate parts of our project and to begin I’m trying to automate the setup of the build machine. The first task is to set the environment variables.

Can this be done in Ruby without using system("%PATH% = %PATH%;c:\ruby\bin") etc.?

Thanks in advance!!! ( :

ENV[‘PATH’] += “c:\ruby\bin”

will be vaild only in processes that you’ll start from your script, in
other words, you cannot modify parent environment. (you could do by
some batch file wizardry)

J.

On 8/14/06, Jan S. [email protected] wrote:

machine. The first task is to set the environment variables.

Can this be done in Ruby without using system("%PATH% =
%PATH%;c:\ruby\bin") etc.?

Thanks in advance!!! ( :

ENV[‘PATH’] += “c:\ruby\bin”

ENV cannot be assigned too.
Sorry :frowning:
Robert

will be vaild only in processes that you’ll start from your script, in

other words, you cannot modify parent environment. (you could do by
some batch file wizardry)

J.


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein

On 8/14/06, Robert D. [email protected] wrote:

ENV cannot be assigned too.

ENV[“PATH”]
=> “C:\Ruby\bin;…”

ENV[“PATH”] += “;C:\tmp”
=> “C:\Ruby\bin;…;C:\tmp”

system(“cmd”)
Microsoft Windows XP [Version 5.1.2600]
© Copyright 1985-2001 Microsoft Corp.

C:\home>PATH
PATH=C:\Ruby\bin;…;C:\tmp

The environment CAN be assigned to. What you can’t do is propagate it
upwards. Any processes you spawn from your Ruby application will use
your new environment table, but you can’t call a Ruby application to
set your environment in its parent.

-austin

On 8/14/06, Austin Z. [email protected] wrote:

© Copyright 1985-2001 Microsoft Corp.

Austin Z. * [email protected] * http://www.halostatue.ca/
* [email protected] * http://www.halostatue.ca/feed/
* [email protected]

This is very nice got my test upwards down, hmmm, ENV is not a hash but
reponds to the same methods as a Hash, thus element assignment.
Sorry for the noise.


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs