From: Jeremy Bopp Date: 2011-11-06T12:25:03+09:00 Subject: Re: help trying to create a build script On 11/05/2011 10:01 PM, Dev Guy wrote: > Hi I am trying to create a build script and I am running into an > issue, apparent I have to cd into the folder before I call make > otherwise make seem to fail. > > If I was at the command like I would just type > > git clone path_to_repository build/ > cd build/mozilla_firefox > make -f client.mk > > however if I try this from a ruby script make barf and fails because > it's expecting to be called from within the foder > build/mozilla_firefox > > system "git clone path_to_repository build/" > system "make -f build/mozilla_firefox/client.mk" > > I also tried the following which doesn't do what I would expect, which > is cd into the folder > > system "git clone path_to_repository build/" > system "cd build/mozilla_firefox" > system "make -f client.mk" > > Do anyone got idea how I can get this build script working? My recommendation here is to generally write a shell script to do what you want and then use the system method to run that single script. However, you can do what you want within Ruby too: system "git clone path_to_repository build/" Dir.chdir("build/mozilla_firefox") do system "make -f client.mk" end The thing to keep in mind is that the system method runs a subprocess to do the work, and a subprocess cannot modify the environment of its parent. The current working directory of a process is part of its environment which is why using system in an attempt to change directories had no effect for your script. -Jeremy