macospackagemacos-sierrachrome-native-messaging

Chrome Native messaging host won't start on macOS Sierra


I use Packages app to install an application and run a post install script that configures the Native messaging host. I require admin rights to for the installation. I had 2 main issues on macOS Sierra (maybe High Sierra too).

The native messaging host is a python3 script, I run command -v python3 on the post install script the to check if python3 is installed, if not the script exits with an error.

When I run the installer on macOS 10.15 (Catalina) everything works es expected (since Catalina comes with python3). I have installed the official python3 pkg and ran the installer again on 2 machines, one is on Catalina so no problem, the other is on Sierra on which the command command -v python3 fails always even though it runs perfectly from terminal.

I now check for python3 in 2 paths using ls /usr/bin/python3 (Catalina's python3) or ls /usr/local/bin/python3 (official python3) and it works perfectly on Sierra and Catalina.

Another issue, only on Sierra, I kept getting the error Unchecked runtime.lastError: Native host has exited. so I tried to run Chrome on debug to see what's going on and I was surprised to discover that the message has disappeared, but I kept getting if if I click to open the app, it works also if I just run open from terminal (keep in mind that everything works perfectly on Catalina). I have tried everything I could think of, I still don't understand what's going on. I have reproduced this issue on 2 other VMs Sierra.

the rights on the nmh script -rwxr-xr-x

Will provide any code you'll need.

UPDATE

See my answer, I will leave the question open as I am curious about the reason I get different behaviours on Catalina and Sierra


Solution

  • it looks like on Sierra Chrome can't interpret the shebang #!/usr/bin/env python3. I solved it by using sed after finding the right python 3 path.