facebook / watchman

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

Hard dependency on Homebrew #1191

Open raxod502-plaid opened 4 months ago

raxod502-plaid commented 4 months ago

For some reason it seems that the watchman build system has a hard dependency on Homebrew:

% ./autogen.sh
+ PREFIX=/usr/local
+ python3 build/fbcode_builder/getdeps.py build --allow-system-packages --src-dir=. --project-install-prefix=watchman:/usr/local watchman
Building on {distro=None, distro_vers=None, fb=off, fbsource=off, os=darwin, shared_libs=off, test=on}
Testing ENV[BOOST_ROOT_1_69_0]: None
Traceback (most recent call last):
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps.py", line 1376, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps.py", line 1359, in main
    return args.func(args)
           ^^^^^^^^^^^^^^^
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps.py", line 108, in run
    self.run_project_cmd(args, loader, manifest)
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps.py", line 562, in run_project_cmd
    fetcher = loader.create_fetcher(m)
              ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps/load.py", line 252, in create_fetcher
    return manifest.create_fetcher(self.build_opts, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps/manifest.py", line 423, in create_fetcher
    if package_fetcher.packages_are_installed():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rrosborough/code/watchman/build/fbcode_builder/getdeps/fetcher.py", line 180, in packages_are_installed
    proc = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rrosborough/.asdf/installs/python/3.11.1/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rrosborough/.asdf/installs/python/3.11.1/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/Users/rrosborough/.asdf/installs/python/3.11.1/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'brew'

This appears to be because there is a hardcoded assumption that all Mac users use Homebrew, which is not the case:

    def get_package_manager(self):
        if not self.is_linux() and not self.is_darwin():
            return None
        if self.is_darwin():
            return "homebrew"
        if self.distro in ("fedora", "centos", "centos_stream"):
            return "rpm"
        if self.distro.startswith(("debian", "ubuntu")):
            return "deb"
        return None

For this reason it's unclear how to build watchman on any Apple-based system without Homebrew. I would have assumed that integration with the system package manager would only be needed if I wanted dependencies to be automatically installed. But that is not what I want, I just want to compile watchman and I can install dependencies by hand.

raxod502-plaid commented 4 months ago

Editing build/fbcode_builder/getdeps/platform.py to change return "homebrew" to return "macports" appears to work around the hard failure.