thoughtbot / terrapin

Run shell commands safely, even with user-supplied values
Other
250 stars 18 forks source link

Define working directory #7

Closed hector closed 6 years ago

hector commented 6 years ago

Is there a way to define the current working directory?

I am running some C binaries from Rails. These binaries use external files in this fashion: ./external_file, that are supposed be run alongside the binary itself, and so the command is supposed to be run from the same folder the binary is. But when running Terrain commands the working folder is the same as the Ruby interpreter working folder (Rails.root in my case). I would be nice to be able to set it.

hector commented 6 years ago

I answer myself (this works for POSIX environments, I haven't tried others):

Cocaine::CommandLine.new 'mycommand', "", runner_options: {:chdir => '/my/working/directory'}