how to compile a program without being in that Dir (via Cmd line)

Discussion in 'OT Technology' started by Er0si0n, Jul 16, 2006.

  1. Er0si0n

    Er0si0n New Member

    Joined:
    Jul 12, 2004
    Messages:
    239
    Likes Received:
    0
    Location:
    Sterling Heights, MI
    I just installed ruby and want to try to start learning a little bit on it. So i installed ruby in to the default directory c:\ruby

    I then created a directory to store my ruby apps in c:\rubyapps

    Now I want to be able to execute my apps in this directory by just typing ruby whatever.rb in that directory, but I can't. I can only do this if i am in the c:\ruby\bin directory and do ruby c:\rubyapps\whatever.rb.

    So my question is how can I make is so i can exec ruby files from any folder not just that bin folder?
     
  2. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    put the location in the global path enviroment variable
     
  3. codemartinet

    codemartinet lucky strikes

    Joined:
    May 25, 2006
    Messages:
    95
    Likes Received:
    0
    Location:
    Newark, DE
    you need to add c:\ruby\bin to your PATH variable

    you can see what your current PATH is by typing 'set PATH' in your command prompt.

    You can change it by going start->settings->control panel->system
    Go to the advanced tab and click on Environment Variables.
    In System Variables you can select the PATH Variable and hit Edit
    Add this exactly (including beginning semicolon) to the end of your path:

    ;c:\ruby\bin

    now close all command prompts you have open, hit apply on your environment variables window and then open a new command prompt. If you type 'set PATH' you should see the new PATH with your ruby bin appended to it.
     
  4. codemartinet

    codemartinet lucky strikes

    Joined:
    May 25, 2006
    Messages:
    95
    Likes Received:
    0
    Location:
    Newark, DE
    The PATH variable basically lists all the directories that the OS should look in to find the executable besides the current working directory (CWD).
     
  5. Er0si0n

    Er0si0n New Member

    Joined:
    Jul 12, 2004
    Messages:
    239
    Likes Received:
    0
    Location:
    Sterling Heights, MI
    Thanks alot Codemartinet for explaining what Cyber suggested, it worked.
     
  6. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    if you didn't know what the PATH variable is, and how to change it, perhaps ruby isn't what you need to study, right now?
     
  7. codemartinet

    codemartinet lucky strikes

    Joined:
    May 25, 2006
    Messages:
    95
    Likes Received:
    0
    Location:
    Newark, DE
    VB perhaps? :coolugh:

    managed CLR code 4tw
     
  8. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    I wouldn't know how to change the PATH on Windows either :embd:
     
  9. codemartinet

    codemartinet lucky strikes

    Joined:
    May 25, 2006
    Messages:
    95
    Likes Received:
    0
    Location:
    Newark, DE
    there is a difference between knowing what a PATH is and not knowing how to set it in a specific OS and not knowing what at PATH is at all or how it works.

    The former lets you search around for your own answer while the latter doesn't give you a place to start your search.
     
  10. Chau

    Chau if i wanted to kill you, i would've come in here s

    Joined:
    May 30, 2000
    Messages:
    95,448
    Likes Received:
    0
    Location:
    CTU
    u shouldve installed rubygem along w/ ruby to set up rails, it sets it up for you

    but if u didnt u can just add c:\ruby\bin to your path variable

    also, checkout radrails, pretty good ide based off eclipse
     

Share This Page