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

Help me get the homebrew formula building again #851

Open isker opened 4 years ago

isker commented 4 years ago

Hello @wez! As per https://github.com/facebook/watchman/issues/665#issuecomment-465404481 I am trying to get the homebrew formula building again. Sadly my knowledge of: homebrew internals; watchman; and native toolchains of any kind are all pretty poor πŸ™‚ .

I made the suggested changes to the formula:

modified   Formula/watchman.rb
@@ -1,21 +1,12 @@
 class Watchman < Formula
   desc "Watch files and take action when they change"
   homepage "https://github.com/facebook/watchman"
+  url "https://github.com/facebook/watchman/archive/v2020.08.17.00.tar.gz"
+  sha256 "9229687ee834b4527746f61a8071a9d1bb16415e948787120703c5f511383e6e"
   license "Apache-2.0"
-  revision 4
+  version_scheme 1
   head "https://github.com/facebook/watchman.git"

-  stable do
-    url "https://github.com/facebook/watchman/archive/v4.9.0.tar.gz"
-    sha256 "1f6402dc70b1d056fffc3748f2fdcecff730d8843bb6936de395b3443ce05322"
-
-    # Upstream commit from 1 Sep 2017: "Have bin scripts use iter() method for python3"
-    patch do
-      url "https://github.com/facebook/watchman/commit/17958f7d.diff?full_index=1"
-      sha256 "edad4971fceed2aecfa2b9c3e8e22c455bfa073732a3a0c77b030e506ee860af"
-    end
-  end
-
   bottle do
     sha256 "7840f564c11d33425c9eb8985f9156e782e66ef2a3578329dba83ee15a9bf0be" => :catalina
     sha256 "ba2338b0f23c8b8817fd7bfa92466b7a97ab416e93ec6c3a400041aef013de86" => :mojave
@@ -26,6 +17,7 @@ class Watchman < Formula
   depends_on "automake" => :build
   depends_on "libtool" => :build
   depends_on "pkg-config" => :build
+  depends_on "folly"
   depends_on "openssl@1.1"
   depends_on "pcre"
   depends_on "python@3.8"

But getdeps.py is, well, still trying to get all of the deps. Right now it's trying and failing to build openssl. I'm not sure why, but I'm pretty sure it shouldn't be trying to build it in the first place.

OpenSSL build error

``` Assessing openssl... Download https://www.openssl.org/source/openssl-1.1.1f.tar.gz -> /private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/downloads/openssl-openssl-1.1.1f.tar.gz ... .. 0 of 9792828 [Complete in 0.834120 seconds] --- + cd /private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/build/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c && \ + /usr/bin/perl \ + /private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/Configure \ + --prefix=/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c \ + --openssldir=/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c \ + darwin64-x86_64-cc \ + enable-static-engine \ + enable-capieng \ + no-makedepend \ + no-unit-test \ + no-tests Configuring OpenSSL version 1.1.1f (0x1010106fL) for darwin64-x86_64-cc Using os-specific seed configuration Creating configdata.pm Creating Makefile ********************************************************************** *** *** *** OpenSSL has been successfully configured *** *** *** *** If you encounter a problem while building, please open an *** *** issue on GitHub *** *** and include the output from the following command: *** *** *** *** perl configdata.pm --dump *** *** *** *** (If you are new to OpenSSL, you might want to consult the *** *** 'Troubleshooting' section in the INSTALL file first) *** *** *** ********************************************************************** --- + cd /private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/build/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c && \ + make \ + install_sw \ + install_ssldirs /usr/bin/perl "-I." -Mconfigdata "../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/util/dofile.pl" \ "-oMakefile" ../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/include/crypto/bn_conf.h.in > include/crypto/bn_conf.h /usr/bin/perl "-I." -Mconfigdata "../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/util/dofile.pl" \ "-oMakefile" ../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/include/crypto/dso_conf.h.in > include/crypto/dso_conf.h /usr/bin/perl "-I." -Mconfigdata "../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/util/dofile.pl" \ "-oMakefile" ../../extracted/openssl-openssl-1.1.1f.tar.gz/openssl-1.1.1f/include/openssl/opensslconf.h.in > include/openssl/opensslconf.h created directory `/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c' created directory `/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c/certs' created directory `/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c/private' created directory `/private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c/misc' Command '['make', 'install_sw', 'install_ssldirs']' returned non-zero exit status 2. !! Failed install ./apps/CA.pl -> /private/tmp/fbcode_builder_getdeps-ZprivateZtmpZwatchman-20200825-72628-nwvu33Zwatchman-2020.08.17.00ZbuildZfbcode_builder/installed/openssl-UtXLnJ2t0v50wqKwl2XtYbrqHH1o2BVeZQYDPt0Ta_c/misc/CA.pl cp: ./apps/CA.pl: No such file or directory make: *** [install_ssldirs] Error 1 make: *** Waiting for unfinished jobs.... ```

Am I supposed to skip autogen.sh and invoke getdeps.py directly with something like --allow-system-packages? If so, I think I'd need to add homebrew dependencies on more than just folly. Boost, for example. Is there a full list handy anywhere?

isker commented 4 years ago

Nevermind Boost, it's a transitive dep of folly:

Ξ» brew deps --include-build --tree watchman
watchman
β”œβ”€β”€ autoconf
β”œβ”€β”€ automake
β”‚   └── autoconf
β”œβ”€β”€ libtool
β”œβ”€β”€ pkg-config
β”œβ”€β”€ folly
β”‚   β”œβ”€β”€ cmake
β”‚   β”‚   └── sphinx-doc
β”‚   β”‚       └── python@3.8
β”‚   β”‚           β”œβ”€β”€ pkg-config
β”‚   β”‚           β”œβ”€β”€ gdbm
β”‚   β”‚           β”œβ”€β”€ openssl@1.1
β”‚   β”‚           β”œβ”€β”€ readline
β”‚   β”‚           β”œβ”€β”€ sqlite
β”‚   β”‚           β”‚   └── readline
β”‚   β”‚           └── xz
β”‚   β”œβ”€β”€ pkg-config
β”‚   β”œβ”€β”€ boost
β”‚   β”‚   └── icu4c
β”‚   β”œβ”€β”€ double-conversion
β”‚   β”‚   └── cmake
β”‚   β”‚       └── sphinx-doc
β”‚   β”‚           └── python@3.8
β”‚   β”‚               β”œβ”€β”€ pkg-config
β”‚   β”‚               β”œβ”€β”€ gdbm
β”‚   β”‚               β”œβ”€β”€ openssl@1.1
β”‚   β”‚               β”œβ”€β”€ readline
β”‚   β”‚               β”œβ”€β”€ sqlite
β”‚   β”‚               β”‚   └── readline
β”‚   β”‚               └── xz
β”‚   β”œβ”€β”€ fmt
β”‚   β”‚   └── cmake
β”‚   β”‚       └── sphinx-doc
β”‚   β”‚           └── python@3.8
β”‚   β”‚               β”œβ”€β”€ pkg-config
β”‚   β”‚               β”œβ”€β”€ gdbm
β”‚   β”‚               β”œβ”€β”€ openssl@1.1
β”‚   β”‚               β”œβ”€β”€ readline
β”‚   β”‚               β”œβ”€β”€ sqlite
β”‚   β”‚               β”‚   └── readline
β”‚   β”‚               └── xz
β”‚   β”œβ”€β”€ gflags
β”‚   β”‚   └── cmake
β”‚   β”‚       └── sphinx-doc
β”‚   β”‚           └── python@3.8
β”‚   β”‚               β”œβ”€β”€ pkg-config
β”‚   β”‚               β”œβ”€β”€ gdbm
β”‚   β”‚               β”œβ”€β”€ openssl@1.1
β”‚   β”‚               β”œβ”€β”€ readline
β”‚   β”‚               β”œβ”€β”€ sqlite
β”‚   β”‚               β”‚   └── readline
β”‚   β”‚               └── xz
β”‚   β”œβ”€β”€ glog
β”‚   β”‚   β”œβ”€β”€ cmake
β”‚   β”‚   β”‚   └── sphinx-doc
β”‚   β”‚   β”‚       └── python@3.8
β”‚   β”‚   β”‚           β”œβ”€β”€ pkg-config
β”‚   β”‚   β”‚           β”œβ”€β”€ gdbm
β”‚   β”‚   β”‚           β”œβ”€β”€ openssl@1.1
β”‚   β”‚   β”‚           β”œβ”€β”€ readline
β”‚   β”‚   β”‚           β”œβ”€β”€ sqlite
β”‚   β”‚   β”‚           β”‚   └── readline
β”‚   β”‚   β”‚           └── xz
β”‚   β”‚   └── gflags
β”‚   β”‚       └── cmake
β”‚   β”‚           └── sphinx-doc
β”‚   β”‚               └── python@3.8
β”‚   β”‚                   β”œβ”€β”€ pkg-config
β”‚   β”‚                   β”œβ”€β”€ gdbm
β”‚   β”‚                   β”œβ”€β”€ openssl@1.1
β”‚   β”‚                   β”œβ”€β”€ readline
β”‚   β”‚                   β”œβ”€β”€ sqlite
β”‚   β”‚                   β”‚   └── readline
β”‚   β”‚                   └── xz
β”‚   β”œβ”€β”€ libevent
β”‚   β”‚   β”œβ”€β”€ autoconf
β”‚   β”‚   β”œβ”€β”€ automake
β”‚   β”‚   β”‚   └── autoconf
β”‚   β”‚   β”œβ”€β”€ libtool
β”‚   β”‚   β”œβ”€β”€ pkg-config
β”‚   β”‚   └── openssl@1.1
β”‚   β”œβ”€β”€ lz4
β”‚   β”œβ”€β”€ openssl@1.1
β”‚   β”œβ”€β”€ snappy
β”‚   β”‚   β”œβ”€β”€ cmake
β”‚   β”‚   β”‚   └── sphinx-doc
β”‚   β”‚   β”‚       └── python@3.8
β”‚   β”‚   β”‚           β”œβ”€β”€ pkg-config
β”‚   β”‚   β”‚           β”œβ”€β”€ gdbm
β”‚   β”‚   β”‚           β”œβ”€β”€ openssl@1.1
β”‚   β”‚   β”‚           β”œβ”€β”€ readline
β”‚   β”‚   β”‚           β”œβ”€β”€ sqlite
β”‚   β”‚   β”‚           β”‚   └── readline
β”‚   β”‚   β”‚           └── xz
β”‚   β”‚   └── pkg-config
β”‚   β”œβ”€β”€ xz
β”‚   └── zstd
β”‚       └── cmake
β”‚           └── sphinx-doc
β”‚               └── python@3.8
β”‚                   β”œβ”€β”€ pkg-config
β”‚                   β”œβ”€β”€ gdbm
β”‚                   β”œβ”€β”€ openssl@1.1
β”‚                   β”œβ”€β”€ readline
β”‚                   β”œβ”€β”€ sqlite
β”‚                   β”‚   └── readline
β”‚                   └── xz
β”œβ”€β”€ openssl@1.1
β”œβ”€β”€ pcre
└── python@3.8
    β”œβ”€β”€ pkg-config
    β”œβ”€β”€ gdbm
    β”œβ”€β”€ openssl@1.1
    β”œβ”€β”€ readline
    β”œβ”€β”€ sqlite
    β”‚   └── readline
    └── xz

Though judging by the list from CI, some deps like ninja are still missing from the formula. https://github.com/facebook/watchman/blob/ebdade398e26e87e73b5aa82e287503bdfcf1f5a/.github/workflows/getdeps_mac.yml#L20-L72

si14 commented 4 years ago

This issue might be related/of interest: https://github.com/facebook/watchman/issues/839

wez commented 4 years ago

Thanks for taking a look at this!

I think fixing up the homebrew formula in core homebrew is probably quite difficult.

The easiest way to build watchman from master today is using our getdeps machinery. That is responsible for fetching, building and composing the dependencies. This is at odds with homebrew's own dependency management, so a proper update to the homebrew formula probably should not use the getdeps stuff.

Another challenge here is that watchman depends on folly and fbthrift and all of those projects use a continuous delivery model in the internal single source repository where they all reside. When we export to github those projects are mapped to separate projects that are hard to relate to each other. We have another piece of infrastructure that will cut a weekly tag to try to form a consistent relationship, but due to the nature of continuous delivery, any of those projects might not actually be buildable with each other due to various transient bugs.

I've been copied on numerous issues in the folly repo over the past few years where folks have been working to resolve build issues that block updating the folly homebrew formula, so I sense that this might turn into an ongoing/uphill battle to keep the formula working.

What I've been leaning towards as a solution for this is to effectively move watchman out of homebrew core and manage it via our taps repo at https://github.com/facebook/homebrew-fb.

We could automatically update the tap as part of our weekly release automation and have it install the most recently successful macos binary build published to our releases section.

This feels like less work for everyone overall, and I have made a proof of concept of this approach in a personal project: https://github.com/wez/wezterm/blob/master/.github/workflows/gen_macos_tag.yml#L85-L108 which updates a tab formula here: https://github.com/wez/homebrew-wezterm/blob/master/Formula/wezterm.rb

I haven't had an opportunity to sit down and make this happen so far, but if you're feeling motivated and have the bandwidth for it, we'd love to see you submit a couple of PRs for this.

What I think needs to happen:

Then we can look at deprecating the homebrew core formula. I think that this will result in something that is easier to maintain overall.

What do you think?

isker commented 4 years ago

This sounds reasonable. Monorepos are The Way πŸ˜‰.

I'm confused about what the collisions/opt part is for though. Won't homebrew link it straight into /usr/local/bin when installing anyway?

wez commented 4 years ago

I'm confused about what the collisions/opt part is for though. Won't homebrew link it straight into /usr/local/bin when installing anyway?

By default, yes, but for example: at FB we have a site specific homebrew deployment set to deploy to /opt/homebrew and there's some other complicated chef stuff happening that manages /usr/local/bin and its permissions which makes it frustrating to use their own user specific stock homebrew. Some people choose to do that anyway, and others do a per-user install. If we hard code /usr/local/bin into the binaries then we make it difficult to co-exist with other configurations of homebrew, the current core brew formula or other distribution systems.

Outside of homebrew/mac, some users have commented that they'd appreciate having the linux binaries not deploy /usr/local so that they can do things like mount them via NFS more easily.

isker commented 4 years ago

So, here's where my inexperience with native {builds,packaging,anything at all} fails me: why would the prefix get baked into the binaries at all? I thought that the prefix was just to tell make install where to copy the binaries.

I set up the formula at https://github.com/facebook/homebrew-fb/pull/41.

kelset commented 3 years ago

hey folks, trying to catch up on this whole conversation; it sounds like, per @isker PR merged last week by @kapji: https://github.com/facebook/homebrew-fb/pull/41 now if someone wants to install watchman via homebrew and not get stuck on the 2017's 4.9.0 version they'd need to:

brew tap facebook/fb
brew install facebook/fb/watchman

correct?

The side problem I'm seeing about this is that @isker's PR "hardcoded" the version in the .rb file to v2020.08.17.00, which at this point is fairly old too (6+ months). Is there a way to update that automatically when a new version is out? Or is the expectation that someone will always have to manually go and override that line in the config?


PS: btw @isker thank you SO MUCH for deciding to drive this problem and make that PR πŸ‘πŸ‘

KapJI commented 3 years ago

As for now, it needs to be maintained manually. Feel free to send PR for the new version.

isker commented 3 years ago

The intent was that, after that initial formula was merged, I would add a script to the release CI tooling for this project that would automatically update the version in that formula and commit.

However that initial PR sat for about 5 months and I no longer have much interest in driving the remaining work. Feel free to pick it up.

On Thu, Feb 18, 2021 at 07:02 Ruslan Sayfutdinov notifications@github.com wrote:

As for now, it needs to be maintained manually. Feel free to send PR for the new version.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebook/watchman/issues/851#issuecomment-781295200, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABH3ZNJGRGEPY3X3NFUSK3LS7T6WBANCNFSM4QK66WAA .

fanzeyi commented 3 years ago

I think I can set up the GitHub action to automatically send PR to the Facebook repo updating the version every release.

KapJI commented 3 years ago

Buck has this implemented here: https://github.com/facebook/buck/blob/master/tools/release/platforms/homebrew.py You can make something similar.

kelset commented 3 years ago

that would be great @fanzeyi πŸ‘ do you know if/when you'll be able to do it?

fanzeyi commented 3 years ago

@kelset maybe later this week. Will update soon =)

fanzeyi commented 3 years ago

Some update, I have a version working and it opened a PR here https://github.com/facebook/homebrew-fb/pull/56 in my testing. I'm now waiting on our open source team for a bot token I can use to make these commits :)

kelset commented 3 years ago

dope πŸ‘ lmk once it works :) I'm planning to do a PR for the react-native docs once it's all set up :)

kelset commented 3 years ago

@fanzeyi any updates on this?