rjeczalik / notify

File system event notification library on steroids.
MIT License
900 stars 128 forks source link

undefined: stream - Issue with Mac OS M2 #222

Open LordMoMA opened 1 year ago

LordMoMA commented 1 year ago

On Linux Ubuntu, it does not have the below problem, but OS M2 has:

# github.com/rjeczalik/notify
../../../pkg/mod/github.com/rjeczalik/notify@v0.9.2/watcher_fsevents.go:49:11: undefined: stream
../../../pkg/mod/github.com/rjeczalik/notify@v0.9.2/watcher_fsevents.go:200:13: undefined: newStream
ReallyLiri commented 1 year ago

stream is defined at https://github.com/rjeczalik/notify/blob/8c8ecfea2ebaf5e526db43df4ccb39a9bb7955ff/watcher_fsevents_cgo.go#L117 Make sure you build with cgo and the other expected flags I guess

LordMoMA commented 1 year ago

If I built with CGO_ENABLED=1, it generates other problems, and the pod could not be spun up

CGO_ENABLED=1 go build -ldflags "-s -w" ./cmd/crypto-tron

CGO_ENABLED=1 go build -ldflags "-s -w" ./cmd/crypto-tron
# github.com/karalabe/hid
In file included from ../../../../.gvm/pkgsets/system/global/pkg/mod/github.com/karalabe/hid@v1.0.0/hid_enabled.go:38:
../../../../.gvm/pkgsets/system/global/pkg/mod/github.com/karalabe/hid@v1.0.0/hidapi/mac/hid.c:693:34: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:133:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
# github.com/rjeczalik/notify
cgo-gcc-prolog:217:2: warning: 'FSEventStreamScheduleWithRunLoop' is deprecated: first deprecated in macOS 13.0 - Use FSEventStreamSetDispatchQueue instead. [-Wdeprecated-declarations]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/FSEvents.framework/Headers/FSEvents.h:1138:1: note: 'FSEventStreamScheduleWithRunLoop' has been explicitly marked deprecated here
ReallyLiri commented 1 year ago

I think most of these warnings were fixed in https://github.com/rjeczalik/notify/pull/215 make sure you using the latest code Anyway, I don't see why deprecation warnings failed the build , you sure that's the whole relevant output?

LordMoMA commented 1 year ago

problem solved by upgrading to the latest version and set CGO_ENABLED=0, why we don't need CGO here?

ReallyLiri commented 1 year ago

If you build without cgo you'd actually be using kqueue and not fsevents. fsevents condition is //go:build darwin && !kqueue && cgo kqueue condition is //go:build (darwin && kqueue) || (darwin && !cgo) || ... kqueue might very well suit your needs, depending on your usage of this library.

LordMoMA commented 1 year ago

thank you for the knowledge here ❤️