facebook / watchman

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

Unable to talk to your watchman on /opt/homebrew/var/run/watchman/[user]-state/sock! #1142

Closed midrizi closed 1 year ago

midrizi commented 1 year ago

Do I have to keep the following command running watchman --foreground --logfile=/dev/stdout or is watchman supposed to run by itself on the background?

Without keeping the above command running, it hangs and throws unable to talk to your watchman...

I tried restarting without success. Looking at Activity Monitor watchman doesn't show unless I execute the command above.

hemith commented 1 year ago

Same here. (M1 Macbook)

~ $ watchman -v 2023.06.12.00

/opt/homebrew/var/run/watchman/a_user-state/log

2023-06-16T11:19:27,186: [client=7:stm=105553145857536:pid=41481] path /Users/a_user/git/a_app is on filesystem type apfs 2023-06-16T11:19:27,187: [client=7:stm=105553145857536:pid=41481] failed to use watcher eden: apfs is not a FUSE file system. 2023-06-16T11:19:27,187: [client=7:stm=105553145857536:pid=41481] failed to use watcher kqueue+fsevents: Not using the kqueue+fsevents watcher as the "prefer_split_fsevents_watcher" config isn't set. 2023-06-16T11:19:27,188: [client=7:stm=105553145857536:pid=41481] root /Users/a_user/git/a_app using watcher mechanism fsevents (auto was requested) 2023-06-16T11:19:27,990: [io 4347414344 /Users/a_user/git/a_app] PERF: {"user_time": 0.082271999999999998, "start_time": 1686881967.1902249, "elapsed_time": 0.80041499999999999, "version": "2023.06.12.00", "system_time": 0.33769900000000003, "meta": {"root": {"recrawl_count": 0, "case_sensitive": false, "watcher": "fsevents", "path": "/Users/a_user/git/a_app"}}, "pid": 41397, "description": "full-crawl"} 2023-06-16T11:19:27,990: [io 4347414344 /Users/a_user/git/a_app] crawl complete 2023-06-16T11:19:29,481: [client=7:stm=105553145857536:pid=41481] PERF: {"user_time": 1.0969139999999999, "start_time": 1686881967.995013, "elapsed_time": 1.486102, "version": "2023.06.12.00", "system_time": 2.6123630000000002, "meta": {"client": {"pid": 41481}, "args": ["query", "/Users/a_user/git/a_app", {"glob_includedotfiles": true, "fields": ["name", "exists", "mtime_ms", "size", "content.sha1hex"], "glob": ["/*.js", "*/.json", "/*.ts", "/*.tsx", "*/.svg", "/*.bmp", "/*.gif", "*/.jpg", "/*.jpeg", "/*.png", "*/.psd", "/*.webp", "/*.m4v", "*/.mov", "/*.mp4", "/*.mpeg", "*/.mpg", "/*.webm", "/*.aac", "*/.aiff", "/*.caf", "/*.m4a", "*/.mp3", "/*.wav", "/*.html", "*/.pdf", "/*.yaml", "/*.yml", "*/.otf", "/*.ttf", "*/.zip"], "expression": ["allof", ["type", "f"], ["suffix", ["js", "json", "ts", "tsx", "svg", "bmp", "gif", "jpg", "jpeg", "png", "psd", "webp", "m4v", "mov", "mp4", "mpeg", "mpg", "webm", "aac", "aiff", "caf", "m4a", "mp3", "wav", "html", "pdf", "yaml", "yml", "otf", "ttf", "zip"]]]}], "root": {"recrawl_count": 0, "case_sensitive": false, "watcher": "fsevents", "path": "/Users/a_user/git/a_app"}}, "pid": 41397, "description": "dispatch_command:query"} Terminating due to signal 15 Terminated generated by pid=1 uid=0 (0) 0 watchman 0x0000000100247f4c _ZL13crash_handleriP9siginfoPv + 556 1 libsystem_platform.dylib 0x000000019e366a24 _sigtramp + 56 2 libsystem_pthread.dylib 0x000000019e33a338 _pthread_join + 440 3 libc++.1.dylib 0x000000019e26e934 _ZNSt316thread4joinEv + 36 4 watchman 0x0000000100260b40 _ZN10AcceptLoopD2Ev + 32 5 watchman 0x000000010025eec0 _Z16w_start_listenerv + 1120 6 watchman 0x0000000100267048 _ZL11run_serviceON8watchman11ProcessLock6HandleE + 396 7 watchman 0x0000000100263c50 _ZL25run_service_in_foregroundv + 68 8 watchman 0x000000010026367c main + 5048 9 dyld 0x000000019dfdff28 start + 2236 2023-06-16T11:20:41,015: [listener] waiting for 1 clients to terminate 2023-06-16T11:20:41,057: [sanitychecks] done with sanityCheckThread 2023-06-16T11:20:45,665: [listener] 2 roots were still live at exit 2023-06-16T11:20:45,666: [listener] Exiting from service with res=true

hemith commented 1 year ago

Recently I migrated from an Intel Mac to Apple Silicon.

The problem seems to be caused by the existence of two watchman programs.

/usr/local/bin/watchman -> ../Cellar/watchman/2023.04.10.00/bin/watchman /opt/homebrew/bin/watchman -> ../Cellar/watchman/2023.06.12.00/bin/watchman

I deleted the x86_64 binaries and the problem doesn't happen again.

watchman watch-del-all
rm -f /usr/local/bin/watchman
rm -rf /usr/local/Cellar/watchman/2023.04.10.00/bin/watchman
midrizi commented 1 year ago

@hemith The issue I have is that watchman doesn't work without executing watchman --foreground --logfile=/dev/stdout, other than that it works. Is there a additional command that I have to run?

hemith commented 1 year ago

@midrizi

I encountered the following error:

Error: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2023-06-16T11:23:04,213: [cli] unable to talk to your watchman on /opt/homebrew/var/run/watchman/a_user-state/sock! (Connection refused)

As I mentioned in the previous comment, I followed the steps and managed to resolve the issue. However, it seems that your situation may be different from mine, and I'm not sure about that specific aspect. I apologize for not being able to provide further assistance.

midrizi commented 1 year ago

@hemith Did you get a popup or give permission to watchman? Seems like the same issue as this one https://github.com/facebook/watchman/issues/839

hemith commented 1 year ago

@midrizi

(MacOS: Ventura) Settings > General > Login Items > Allow in Background watchman > ON

midrizi commented 1 year ago

@hemith watchman doesn't show up in Settings.

midrizi commented 1 year ago

I created a shell script with Automator that runs watchman --foreground --logfile=/dev/stdout, and added it to Login Items in Settings.