ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
11.97k stars 545 forks source link

`dyld: Library not loaded: /usr/lib/swift/libswift_Concurrency.dylib` on v0.12.1 for macOS 11.6 #801

Open ErikBjare opened 2 years ago

ErikBjare commented 2 years ago

The following was posted in: https://github.com/ActivityWatch/activitywatch/issues/787#issuecomment-1260766761


Unfortunately, v0.12.1 didn't work for me. There are no errors in the logs now:

➜  ~ cat ~/Library/Logs/activitywatch/aw-watcher-window/aw-watcher-window_2022-09-28T16-39-12.log 
2022-09-28 16:39:12 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
2022-09-28 16:39:13 [INFO ]: Using swift strategy, calling out to swift binary  (aw_watcher_window.main:67)
2022-09-28 16:39:13 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)

But it seems that the afk-watcher-window is not running as seen from the ps output

➜  ~ ps aux|grep ActivityWatch|grep -v grep
umar              1424   0.4  0.5  5205432  81832   ??  S     4:38PM   0:04.11 /Applications/ActivityWatch.app/Contents/MacOS/aw-qt
umar              1436   0.3  0.3  4492020  47588   ??  S     4:38PM   0:01.61 /Applications/ActivityWatch.app/Contents/MacOS/aw-watcher-afk
umar              1434   0.0  0.3  4376404  43864   ??  S     4:38PM   0:01.29 /Applications/ActivityWatch.app/Contents/MacOS/aw-server

Running it manually would give the following error:

➜  ~ /Applications/ActivityWatch.app/Contents/MacOS/aw-watcher-window
 2022-09-28 16:44:17 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
usage: A cross platform window watcher for Activitywatch.
Supported on: Linux (X11), macOS and Windows.
       [-h] [--host HOST] [--port PORT] [--testing] [--exclude-title] [--verbose]
       [--poll-time POLL_TIME] [--strategy {jxa,applescript,swift}]
usage: A cross platform window watcher for Activitywatch.
Supported on: Linux (X11), macOS and Windows.
       [-h] [--host HOST] [--port PORT] [--testing] [--exclude-title] [--verbose]
       [--poll-time POLL_TIME] [--strategy {jxa,applescript,swift}]
A cross platform window watcher for Activitywatch.
Supported on: Linux (X11), macOS and Windows.: error: unrecognized arguments: -B -S -E -s -c from multiprocessing.resource_tracker import main;main(5)
A cross platform window watcher for Activitywatch.
Supported on: Linux (X11), macOS and Windows.: error: unrecognized arguments: --multiprocessing-fork tracker_fd=6 pipe_handle=8
2022-09-28 16:44:18 [INFO ]: Using swift strategy, calling out to swift binary  (aw_watcher_window.main:67)
dyld: Library not loaded: /usr/lib/swift/libswift_Concurrency.dylib
  Referenced from: /Applications/ActivityWatch.app/Contents/MacOS/aw_watcher_window/aw-watcher-window-macos
  Reason: image not found
2022-09-28 16:44:19 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)

Changing the method to jxa also doesn't work with the following logs

Exception: jxa error: Error: Error: An error occurred.
2022-09-28 16:49:36 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 55, in get_current_window
  File "aw_watcher_window/lib.py", line 27, in get_current_window_macos
  File "aw_watcher_window/macos_jxa.py", line 64, in getInfo

I'm on macOS Big Sur (v11.6.1)

Any help is appreciated! Thanks :)

Edit: I also get an error pop-up, that I hadn't noticed before, everytime activitywatch opens up. There's no error in the details. But it's consistently crashing

image

Originally posted by @Gleek in https://github.com/ActivityWatch/activitywatch/issues/787#issuecomment-1260766761

ErikBjare commented 1 year ago

@modderme123 Any idea how to fix this? :)

milomg commented 1 year ago

One reason might be because we're somehow building for a newer macos version that doesn't support async networking stuff. We probably need to explicitly set a flag to build for an older version and unfortunately probably also pull in a library to do network requests without modern swift networking (which comes in macos 10.14 I think, so this is probably not why it is failing here)

The other guess I have is also related to building this and that somehow if we don't build with xcode we're building a dev version that requires command line tools and xcode to be installed...

Probably running xcode-select --install will fix it (but isn't an ideal fix)

Gleek commented 1 year ago

Probably running xcode-select --install will fix it (but isn't an ideal fix)

This isn't the case for me as I have them installed already.

➜  ~ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
milomg commented 1 year ago

@Gleek Would you mind posting your version of xcode and swift?

Gleek commented 1 year ago

@modderme123 Does this help?

➜  ~ xcrun swift -version

Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-darwin20.6.0
➜  ~ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

package-id: com.apple.pkg.CLTools_Executables
version: 13.2.0.0.1.1638488800
volume: /
location: /
install-time: 1639516865
groups: com.apple.FindSystemFiles.pkg-group 

I don't have the full Xcode installation present. I only have the command line tools installed.

0xlevel commented 1 year ago

I have the same issue as @ErikBjare on macOS Version 11.7.2 with identical Swift and pkgutil versions as @Gleek. My error message (also the same besides the timestamps):

2023-01-29 13:50:31 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
2023-01-29 13:50:32 [INFO ]: Using swift strategy, calling out to swift binary  (aw_watcher_window.main:67)
2023-01-29 13:50:32 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)

This also happened using macOS Version 11.7.3.

Switching the strategy_macos in the aw-watcher-window.toml config did not resolve the problem for me → same error.

Also, I was unable to build from source with macOS 11 (as expected, since macOS 12.0 seems to be required):

Installing the current project: aw-watcher-window (0.2.0)
# if macOS, build swift
if [ "Darwin" = "Darwin" ]; then \
        make build-swift; \
    fi
swiftc aw_watcher_window/macos.swift -o aw_watcher_window/aw-watcher-window-macos
aw_watcher_window/macos.swift:189:53: error: 'upload(for:from:delegate:)' is only available in macOS 12.0 or newer
    let (_, response) = try await URLSession.shared.upload(for: urlRequest, from: payload)

I intent to stay on macOS 11 for the weeks to come. If I can help out by running any possibly fixed versions on my system, please let me know.

BelKed commented 1 year ago

Looks like there's a solution described in this blog post: https://nonstrict.eu/blog/2023/using-async-await-in-a-commandline-tool-on-older-macos-versions

Unfortunately, I wasn't able to make the changes to the aw-watcher-window package to confirm this :(

schackbrian2012 commented 1 year ago

@BelKed You referred me to this issue from "Module aw-watcher-window quit unexpectedly." I am using macOS BigSur 11.2.3. If I understand correctly, then ActivityWatch is not compatible with this version of macOS. If I upgrade to the latest version of macOS, then will that solve the issue?

BelKed commented 1 year ago

Yes, upgrading to macOS Monterey will solve the problem :) (I can confirm this because I'm running ActivityWatch on macOS Monterey without any issues)

schackbrian2012 commented 1 year ago

@BelKed Okay, I will back up and upgrade macOS.

schackbrian2012 commented 1 year ago

@BelKed Good news! I upgraded to macOS Ventura 13.4.1, and ActivityWatch is tracking time again. Thank you for your help.