andy-portmen / native-client

Native Messaging component for Windows, Linux, and Mac OS that is written in NodeJS.
https://add0n.com/open-in.html
Mozilla Public License 2.0
727 stars 474 forks source link

Cannot get to work with any Chromium #138

Closed dxlr8r closed 3 months ago

dxlr8r commented 3 months ago

Tested with debian built in, Ungoogled Chronium and Thorium (different config dir, but I just moved the files over). It seem unable to contact the native client:

[6732:6775:0828/211331.510049:WARNING:native_process_launcher.cc(185)] Can't find manifest for native messaging host com.add0n.node

It works from Firefox (to Chromium), though. The extension also state: Log: Specified native messaging host not found.

andy-portmen commented 3 months ago

Most likely the native client cannot find the manifest. Path is not correct. Enable logging to get more info; https://www.chromium.org/for-testers/enable-logging/

dxlr8r commented 3 months ago

I did enable logging. This line from first post is from the log:

[6732:6775:0828/211331.510049:WARNING:native_process_launcher.cc(185)] Can't find manifest for native messaging host com.add0n.node
andy-portmen commented 3 months ago

Have you copied the manifest directory from Chrome to Ungoogled Chromium?

~/.config/google-chrome/NativeMessagingHosts/ to ~/.config/ungoogled-chromium/NativeMessagingHosts/ and ~/.config/thorium/NativeMessagingHosts/

dxlr8r commented 3 months ago

The installer installs to chromium, and yes, for the other two I did copy as well. I also have the same error with "regular" "debian" chromium (which uses ~/.config/chromium).

Also:

$ cat ~/.config/chromium/NativeMessagingHosts/com.add0n.node.json
{
    "name": "com.add0n.node",
    "description": "Node Host for Native Messaging",
    "path": "/home/simen/.config/com.add0n.node/run.sh",
    "type": "stdio",
    "allowed_origins": ...
}
$ cat /home/simen/.config/com.add0n.node/run.sh
#!/usr/bin/env bash
/usr/bin/node $(dirname "$0")/host.js
$ which node
/usr/bin/node
$ echo 'console.log("Hello World!");' | node -
Hello World!

So to me it seems like everything is in order. I am not browser developer though, but could the shift to manifest v3 be the culprit?

andy-portmen commented 3 months ago

I just tried Ungoogled Chromium on Debian and it works for me with the default ~/.config/chromium. Are you trying to connect a developer extension or the official one?

S1

S2

dxlr8r commented 3 months ago

All my three Chromiums are clean installs with your extention from the Chrome Store. For Ungoogled Chromium, I dragged and dropped the crx.

https://chromewebstore.google.com/detail/lmeddoobegbaiopohmpmmobpnpjifpii

andy-portmen commented 3 months ago

I dragged and dropped the crx.

What is the extension id? Open the options page and paste the URL here.

dxlr8r commented 3 months ago

I dragged and dropped the crx.

What is the extension id? Open the options page and paste the URL here.

chrome-extension://lmeddoobegbaiopohmpmmobpnpjifpii/data/helper-firefox/index.html

I did check that as well. And with the other two, I used Chrome Web Store as I said.

One thing though, I use Sway, and no not have XWayland. So I execute using --ozone-platform=wayland. But, it does work with Firefox, and if I remember correct Brave.

andy-portmen commented 3 months ago

I'm unsure what the issue is, but it's possible that the browser is searching for the manifest file in a different directory. I was hoping to find some clues in the logs.

dxlr8r commented 3 months ago
$ strace -yftTe trace=open,read -o log  chromium --ozone-platform=wayland
$ tail -f log | grep ENOENT
16221 09:23:52 access("/etc/chromium/native-messaging-hosts/com.add0n.node.json", F_OK) = -1 ENOENT (No such file or directory) <0.000029>

Seems like it is trying native-messaging-hosts and not NativeMessagingHosts

dxlr8r commented 3 months ago

After doing:

cp -R ~/.config/chromium/NativeMessagingHosts/ /etc/chromium/native-messaging-hosts

It works. Dunno why it does not look in my home dir.

dxlr8r commented 3 months ago

After some more digging, I noticed NativeMessagingUserLevelHosts being false in:

/etc/chromium/policies/managed/policies.json

Setting it to true, it now reads from my home directory.

Also, I did purge and delete chromium's config directories in /etc (chromium and chromium.d), then reinstalling Ungoogled Chromium, so this setting seems to be default for Ungoogled Chromium atleast, might be for others as well.

That also explains why it did not work with any Chromium flavour, as their installer will not overwrite the configuration in /etc set by another Chromium installation. Now, I do not remember which Chromium I did install first, but as I said above, Ungoogled Chromium, at least, set this.

I think you installer should at least check if the value is false, and tell the user.

dxlr8r commented 3 months ago

@andy-portmen thanks for help, you can close this case at your convenience. You can follow it up anyway you want, create a feature from it, or just close it and refer to it if anyone else has the issue.