facebook / watchman

Watches files and records, or triggers actions, when they change.
https://facebook.github.io/watchman/
MIT License
12.57k stars 987 forks source link

Wrong PATH in processes triggered by watchman #1022

Closed nkoson closed 2 years ago

nkoson commented 2 years ago

Using watchman 2022.03.21.00 installed via homebrew on osx 11.6.5, processes triggered by watchman have a different PATH than the ones launched from the user shell. This is unfortunate, because now watchman runs binaries from /usr/bin instead of /usr/local/bin (which have swapped places in the two PATHs mentioned above).

Upon startup, watchman writes ~/Library/LaunchAgents/com.github.facebook.watchman.plist in which the incorrect PATH is shown. Where is this coming from? Overwriting the file does not help since watchman rewrites it on every startup.

I would like to see env display the same PATH regardless whether it was run from the user shell or by watchman.

chadaustin commented 2 years ago

See the logic here: https://github.com/facebook/watchman/blob/main/watchman/main.cpp#L471

If you want a different PATH, I would recommend setting the subprocess_path_env config.

The reason why Watchman uses a consistent PATH is because if it's daemonized in some arbitrary context, the PATH variable of the process spawning Watchman may not be what you want easier, and it's quite confusing to debug in practice.

I'm going to mark this closed, but let me know if subprocess_path_env doesn't work for you.