Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brotab install apparently failed to set the appropriate registry key, and did not detect this issue #64

Open
drocta opened this issue Jan 24, 2022 · 3 comments

Comments

@drocta
Copy link

drocta commented Jan 24, 2022

I am running windows 11. The user I am logged in as is not an admin. I am not sure if this is related.
By manually modifying my registry, I was able to get it to work. What follows is the steps I took.
When I ran brotab install, it said

Installing mediator manifest C:\Users\madaco/.mozilla/native-messaging-hosts/brotab_mediator.json
Setting registry key "Software\Mozilla\NativeMessagingHosts\brotab_mediator" to "C:\Users\madaco\.mozilla\native-messaging-hosts\brotab_mediator.json"
Installing mediator manifest C:\Users\madaco/.config/chromium/NativeMessagingHosts/brotab_mediator.json
Installing mediator manifest C:\Users\madaco/.config/google-chrome/NativeMessagingHosts/brotab_mediator.json
Setting registry key "Software\Google\Chrome\NativeMessagingHosts\brotab_mediator" to "C:\Users\madaco\.config\google-chrome\NativeMessagingHosts\brotab_mediator.json"
Installing mediator manifest C:\Users\madaco/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/brotab_mediator.json
Setting registry key "Software\BraveSoftware\Brave-Browser\NativeMessagingHosts\brotab_mediator" to "C:\Users\madaco\.config\BraveSoftware\Brave-Browser\NativeMessagingHosts\brotab_mediator.json"
Link to Firefox extension: https://addons.mozilla.org/en-US/firefox/addon/brotab/
Link to Chrome (Chromium)/Brave extension: https://chrome.google.com/webstore/detail/brotab/mhpeahbikehnfkfnmopaigggliclhmnc/

I had the firefox browser extension installed, and restarted firefox. running bt clients did not output anything (except an empty line) before finishing.

I looked at the extension debug tools (in about:debugging) and saw that the extension logged that the connection had been closed.
I also noted that the code lisening for disconnects did not manage to find the error message.
The code

port.onDisconnect.addListener(function() {
  console.log("Disconnected");
  if(chrome.runtime.lastError) {
    console.warn("Reason: " + chrome.runtime.lastError.message);
  } else {
    console.warn("lastError is undefined");
  }
});

gave me only "lastError is undefined".
(aside : I'm not especially familiar with js stuff. Is that variable chrome there specific to the browser called "chrome", and that's why the chrome.runtime.lastError is null for me, or is that variable present regardless of which browser? I'm guessing the latter?)
Looking at the object port returned by the runtime.connectNative call, I found that it had an error field saying that the application didn't exist (sorry, I no longer have the exact error message available, didn't think to document this until after I got it working)
I found https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#manifest_location and tried to find whether any of those registry keys had been set.
In regedit, I did not find any of them, neither in HKEY_CURRENT_USER nor in HKEY_LOCAL_MACHINE
Creating a registry entry Computer\HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\brotab_mediator with the content (in my case) C:\Users\madaco\.mozilla\native-messaging-hosts\brotab_mediator.json (which is what bt install claimed to set it to, and where I had previously confirmed that the file referred to there exists), seems to have solved the problem.

suggested changes to make this easier to debug in the future:

  • I think it would be good if the error message from the disconnect would check the port object for the error state, so that it could hopefully identify when the issue is that it doesn't have a program to run.
    • It might be even nicer if this error message was visible without needing to go to the extension debug area (which I initially did not know existed) . Though, short of having the extension show up in next to the url bar (in order to be able to display an error indicator) and take up space there, I don't know what your options are in this area, so it wouldn't surprise me if there are no options for this which would be worth it.
  • If brotab install is unable to set the proper registry, it would be good if it would say so. Initially I thought that it had just set one in the wrong place, but I could not find any of the registry entries it claimed to create.
    Or, I have not tracked down the reason why the registry entry was not created, so maybe the problem isn't that it couldn't create it?
  • In any case, it said it created the registry entries, and either it didn't, or it put them in the wrong place, and it would be better if it created them in the right place, or made it clear that it failed to do so

Side note : It also did not work in chrome when installing the extension on chrome, though I have not tested the registry entry fix on chrome.

Sorry if I'm being presumptuous. Part of this is just that I want what problem I had + the solution, documented, in case others have the same issue.

Edit: I tried looking at the values the python module winreg gives when trying to access those values, and it sees the values as being set. This to me seems very strange, because they do not appear when using regedit. I have no explanation for this.

@AJolly
Copy link

AJolly commented Mar 1, 2024

Thanks for documenting this, it's what I needed to get brotab running. I can confirm even running with admin rights does not get those reg entries set.

@drocta
Copy link
Author

drocta commented Mar 1, 2024

Thank you for confirming that, and I'm glad documenting it helped!

I decided to search again for the reason why winreg saw the changes that should have been made to the registry, while I didn't see them in regedit (until I put them there myself).
I encountered this stack overflow answer about someone having a similar issue with the winreg module : https://stackoverflow.com/a/73452030/6395463 , and the answer there said that they found that this issue occurs for them because they were using the version of python that comes through the windows store, which, for some reason, redirects what one does with winreg to some other location (I guess maybe some like, registry that is only used by windows store apps or something? not sure.)
And, the version of python I installed, regrettably, is the version that comes from the windows store.
@AJolly , is the version of python you have installed, also the one that came through the windows store?
If so, then I think we've found our culprit!

Edit: I believe it would be good to have brotab check whether 'WindowsApps' in sys.executable (or platform.sys.executable)when it is trying to set up the registry stuff, and if that conditions returns true, then warn the user that the registry settings might not have been set correctly.

@AJolly
Copy link

AJolly commented Mar 1, 2024

I'm not 100% sure, but I would have intentionally installed Python from the windows store.

Perhaps the easiest workaround would be to have it generate the registry files, and have to use your manually run those.

Or shell execute a reg add

The documentation also wasn't quite clear I didn't realize I needed to do BT install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants