Use full path to executable in Daemon.spawn
commitfbe520ba3ae0cfa5ee57dfca184289e6711a859e
authorMarshall Roch <mroch@fb.com>
Fri, 4 Sep 2015 02:34:02 +0000 (3 19:34 -0700)
committerJoelMarcey <joelm@fb.com>
Fri, 4 Sep 2015 04:12:56 +0000 (3 21:12 -0700)
treec0cb87b05eb1b59a3ee7c7f0508e9a3526ac11b7
parent4182da8d2455529874d4e751eea4ad4df80b01df
Use full path to executable in Daemon.spawn

Summary: `argv[0]` is not always correct enough to find the binary. One repro we've found so far is when you have an unexpanded `~` in `PATH`, e.g. `PATH='~/flow/bin/':/usr/bin flow ...` (note the single quotes). Bash does expansion to find `~/flow/bin/flow`, but when ocaml reads `PATH`, it just sees `~/flow/bin/` and doesn't do any expansion, so can't find the executable.

`Sys_utils.executable_path ()` does the expansion.

One concern is that this may not be Windows compatible. However, switching to `Daemon.spawn` caused flow to regress because of this, so we should probably fix it and then unbreak Windows if necessary.

Reviewed By: @gabelevi

Differential Revision: D2412005
hphp/hack/src/utils/daemon.ml