Setting Windows Environment Variables

  • Thread starter Cameron, Gemma (UK)
  • Start date
C

Cameron, Gemma (UK)

Hi all!

I'm another Ruby noob and wondered if any of you can help me with my=
problem.=0D

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.=0D

Can this be done in Ruby without using system("%PATH% =3D=
%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.
********************************************************************
 
J

Jan Svitok

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.
 
A

Austin Ziegler

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]
(C) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top