jj-vcs/jj

Homebrew-installed `watchman` on MacOS encounters permission error when trying to write `com.github.facebook.watchman.plist`

Open

#4,064 opened on Jul 10, 2024

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (28,830 stars) (1,052 forks)batch import
documentation 📖good first issuepolish🪒🐃🍎Mac🐛bug

Description

Description

A Homebrew-installed copy of watchman may not have yet created the ~/Library/LaunchAgents/com.github.facebook.watchman.plist file. When this happens, https://github.com/facebook/watchman/issues/326 may occur; that is, ~/Library/LaunchAgents/ may be owned by root, which blocks watchman from creating a new file there as the logged-in user.

See also Apple's docs. on how auto-starting user processes can work via launchd integration in Apple's docs., notably the "The launchd Startup Process" section.

Steps to Reproduce the Problem

  1. Set up a fresh install of jj and watchman via brew on your M1 Mac, presumably as follows:

    $ brew install jj watchman
    
  2. Configure jj to use watchman with a snapshot trigger, i.e., run the commands below. See also 0.19's docs for this:

    jj config set --repo core.fsmonitor watchman
    jj config set --repo core.watchman.register_snapshot_trigger true
    
  3. Run jj debug watchman status.

Expected Behavior

I expect a successful setup of watchman and jj's usage of it, emitting output like the following:

$ jj debug watchman status
Watchman is enabled via `core.fsmonitor`.
Background snapshotting is enabled. Use `core.watchman.register_snapshot_trigger` to control it.
The watchman server seems to be installed and working correctly.
Background snapshotting is currently active.

Actual Behavior

$ jj debug watchman status
Watchman is enabled via `core.fsmonitor`.
Background snapshotting is enabled. Use `core.watchman.register_snapshot_trigger` to control it.
Internal error: Failed to access working copy state
Caused by:
1: Failed to query watchman
2: Filesystem monitor error
3: Could not connect to Watchman
4: While invoking the watchman CLI to discover the server connection details: reader error while deserializing, stderr=`2024-07-10T09:33:40,001: [cli] Failed to open /Users/<snip>/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied
Fatal error detected at:
0   libfolly.0.58.0-dev.dylib           0x0000000103676e98 _ZN5folly10symbolizer17getStackTraceSafeEPmm + 12
1   libfolly.0.58.0-dev.dylib           0x0000000103678088 _ZN5folly10symbolizer21SafeStackTracePrinter15printStackTraceEb + 80
2   watchman                            0x0000000100ee0bac _ZL15log_stack_tracev + 64
3   watchman                            0x0000000100ee0ae8 _ZN8watchman3Log13doLogToStdErrEv + 552
4   watchman                            0x0000000100ede17c _ZN8watchman9Publisher7enqueueEO8json_ref + 464
5   watchman                            0x0000000100e48ac8 _ZN8watchman3Log3logIJRA16_KcRA4096_cRA13_S2_NSt3__112basic_stringIcNS9_11char_traitsIcEENS9_9allocatorIcEEEERA2_S2_EEEvNS_8LogLevelEDpOT_ + 384
6   watchman                            0x0000000100e41a1c main + 2188
7   dyld                                0x000000018e33a0e0 start + 2360
(safe mode, symbolizer not available)
`

Specifications

  • Platform: MacOS. Unclear if the fact that I'm using an M1 Mac is relevant, but I don't think so?
  • Version: 14.5 (Sonoma)

Contributor guide