falood/file_system

Can't find executable `mac_notifier`

dkarter opened this issue · 7 comments

Hi @falood,

I am trying to use this package from another package (exsync) and keep getting this error message in my console:

16:54:02.170 [error] Can't find executable `mac_listener`

I am running macOS Mojave 10.14.4 and have tried installing mac_listener by running the pkg file as per the README:

On Macos 10.14, you need run `open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg` to compile `mac_listener`.

Installation finished successfully and I even restarted my machine, but I still get the error.

I suspect something is off with my PATH setting. So maybe it would help if you could just reply with the output of this command: which mac_listener.

Thank you!

hi @dkarter
the mac_listener should not be founded by which because it's not in the PATH, you should find it at /deps/file_system/priv.
can you try mix deps.compile file_system to check whether the issue reproduced?

Thanks @falood !! This was a very good pointer.

I checked the contents of the /deps/file_system/priv and it only had inotifywait.exe in it:

❯ l deps/file_system/priv
total 16K
drwxr-xr-x  3 dorian  96 Apr 20 11:33 ./
drwxr-xr-x 10 dorian 320 Apr 20 11:33 ../
-rw-r--r--  1 dorian 15K Apr 20 11:33 inotifywait.exe

After running mix deps.compile file_system I got this:

❯ mix deps.compile file_system

11:39:13.980 [info]  Compiling file system watcher for Mac...

11:39:14.505 [info]  Done.
==> file_system
Compiling 7 files (.ex)
Generated file_system app

and subsequently the mac_listener file appeared in the location you specified:

❯ l deps/file_system/priv
total 32K
drwxr-xr-x  4 dorian 128 Apr 20 11:39 ./
drwxr-xr-x 10 dorian 320 Apr 20 11:38 ../
-rw-r--r--  1 dorian 15K Apr 20 11:38 inotifywait.exe
-rwxr-xr-x  1 dorian 16K Apr 20 11:39 mac_listener*

But still the app couldn't find it, so I copied the file into my /usr/local/bin dir, restarted the app and everything started working fine.

I'm not sure why it didn't work out of the box though. I can try and create a small project that would replicate the issue and submit it. Otherwise hopefully the next person encountering this would find this post useful.

Thanks again!

here's the code how file_system find the executable file, it should match :priv as your description.
https://github.com/falood/file_system/blob/master/lib/file_system/backends/fs_mac.ex#L62-L86

This might not be directly related to the above problem — I had the same error, had a different outcome but I am putting it here for posterity in case it helps someone else.

I got the following error:

[error] Can't find executable `mac_listener`

But for me mix deps.compile file_system did not work. I got the following error:

[error] Could not compile file system watcher for Mac, try to run "clang -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener" manually inside the dependency.

I also saw the following instruction in the docs, and decided to run that in case there was an issue:

On Macos 10.14, you need run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg to compile mac_listener.

I figured that might be a missing step. As it turns out this was installed already, but I figured I'd reinstall. But the reinstallation failed. So, I ran the following command as previously suggested.

clang -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener

This... didn't work, but I replaced clang with gcc and it worked. Sorted!

This... didn't work, but I replaced clang with gcc and it worked. Sorted!

Same here. I don't know whether it applies to him, but on my environment, just clang points a nix installed one.

> which clang
/nix/store/yijjgydj0r9pjhl1bnc6zraa1zirkc6r-clang-wrapper-11.1.0/bin/clang

> which gcc  
/usr/bin/gcc

Calling /usr/bin/clang also makes the build succeed.

> clang -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener
In file included from c_src/mac/cli.c:2:
In file included from c_src/mac/cli.h:4:
c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from c_src/mac/compat.c:1:
c_src/mac/compat.h:16:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from c_src/mac/main.c:1:
c_src/mac/common.h:5:10: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

> /usr/bin/clang -framework CoreFoundation -framework CoreServices -Wno-deprecated-declarations c_src/mac/*.c -o priv/mac_listener

(build pass)

Perhaps the cmd should use /usr/bin/clang ?

PR #87 should fix that issue, as it makes compilation step recognise CFLAGS environment variable that will allow Nix to point to correct frameworks directory.

Thanks all!