macosfile-permissionschrome-native-messaging

Failed to connect: Native host has exited


I have been trying to communicate between Chrome Extension and App using Chrome Native Messaging API. I have throughly followed steps/instructions mentioned at DeveloperChrome Website. After downloading sample native messaging app from NativeMessaging Examples, completed its setup by running install_host.sh. When I click on connect button in demo application, it fails with error:

Failed to connect: Native host has exited.

Besides this I ran Chrome instance from terminal in debugging mode by enabling its logs using command

open /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome 
--args --enable-logging --v=1

I found that something has been going wrong with permissions. Permissions of the file accessed are Read&Write for everyone. This issue is specifically related to MacOS as same example worked fine on Windows. Here are the Chrome error logs:

/usr/local/Cellar/python@2/2.7.17_1/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/Users/XXX/Desktop/host/native-messaging-example-host': [Errno 1] Operation not permitted


Solution

  • I'm a bit late here, but I just ran into this too. I managed to fix it by moving my host app into /Applications.

    I suspect this is related to a Catalina permissions issue, though I wasn't able to find anything relevant in the "Security & Privacy" tab of System Preferences.