emeraldemon emeraldemon - 1 month ago 5x
Ruby Question

How can I change directories in a homebrew formula?

I am trying to create my own homebrew formula using

brew create
brew edit

As part of the install for this project I need to change into a sub directory and build things there, for example

cd sub/dir/place
make -f makefile otherMakeTarget

I tried adding to my formula.rb

system "cd", "sub/dir/place/"
system "make", "etc"

But it doesn't seem to do the cd correctly. The logfile 01.cd shows the cd and the argument on two separate lines, I'm not sure if that's the problem.


Calling system creates a subshell and any modifications to the working directory go away when that call completes.

You could try using chdir: