Setting Windows Environment Variables

Discussion in 'Ruby' started by Cameron, Gemma (UK), Aug 14, 2006.

  1. 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.
    ********************************************************************
     
    Cameron, Gemma (UK), Aug 14, 2006
    #1
    1. Advertising

  2. Cameron, Gemma (UK)

    Jan Svitok Guest

    On 8/14/06, Cameron, Gemma (UK) <> 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.
     
    Jan Svitok, Aug 14, 2006
    #2
    1. Advertising

  3. On 8/14/06, Robert Dober <> 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]
    (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
    --
    Austin Ziegler * * http://www.halostatue.ca/
    * * http://www.halostatue.ca/feed/
    *
     
    Austin Ziegler, Aug 14, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Kasten

    Setting Environment Variables

    Rick Kasten, Jul 7, 2004, in forum: Perl
    Replies:
    2
    Views:
    598
    Howard
    Jul 7, 2004
  2. =?Utf-8?B?YnNmbDQ0?=
    Replies:
    0
    Views:
    488
    =?Utf-8?B?YnNmbDQ0?=
    May 12, 2004
  3. Steve
    Replies:
    6
    Views:
    24,097
    lightsedge
    May 1, 2007
  4. Replies:
    5
    Views:
    660
  5. Afaque Ahmad
    Replies:
    2
    Views:
    681
    Brian Schröder
    May 26, 2005
Loading...

Share This Page