glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.68k stars 144 forks source link

firenvim doesn't know to check for or install manifests for non-GA Firefox versions #1481

Closed hwine closed 1 year ago

hwine commented 1 year ago

What I tried to do

Install Firenvim (from WSL Neovim) to support my Firefox browser in win11.

What happened

Firenvim tried to find win11 browsers, but failed to detect them. I have Firefox, Firefox-Nightly, and Edge installed in win11.

call firenvim#install(0)
No config detected for chromium. Skipping.
No config detected for ungoogled-chromium. Skipping.
No config detected for librewolf. Skipping.
No config detected for opera. Skipping.
No config detected for brave. Skipping.
No config detected for vivaldi. Skipping.
No config detected for chrome-dev. Skipping.
Installed native manifest for firefox.
No config detected for chrome-canary. Skipping.
No config detected for chrome. Skipping.
No config detected for edge. Skipping.
Installation complete on the wsl side.
Performing install on the windows side.
No config detected for chromium. Skipping.
No config detected for ungoogled-chromium. Skipping.
No config detected for librewolf. Skipping.
No config detected for opera. Skipping.
No config detected for brave. Skipping.
No config detected for vivaldi. Skipping.
No config detected for chrome-dev. Skipping.
No config detected for firefox. Skipping.
No config detected for chrome-canary. Skipping.
No config detected for chrome. Skipping.
No config detected for edge. Skipping.
Press ENTER or type command to continue

There are 2 potential issues here:

Personally, I'm happy to see the 2nd one just documented. (It's not clear whatthe registry entries should be for firenvim-in-wsl, and I can't inspect a working install due to the first issue.)

BTW, I should note that I'm entering this text using firenvim from Firefox-in-wsl, so firenvim is working just fine. Thanks for a wonderful extension.

hwine commented 1 year ago

Update: There are some assumptions about wsl which aren't always valid. In an effort to get an example of valid windows registry entries, I ran call firenvim#install(1).

Installed native manifest for chromium.
Installed native manifest for ungoogled-chromium.
Installed native manifest for librewolf.
Installed native manifest for opera.
Installed native manifest for brave.
Installed native manifest for vivaldi.
Installed native manifest for chrome-dev.
Installed native manifest for firefox.
Aborting installation for chrome-canary. Chrome Canary doesn't exist on Linux
Installed native manifest for chrome.
Installed native manifest for edge.
Installation complete on the wsl side. Performing install on the windows side.
Installed native manifest for chromium.
Creating registry key for chromium. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/chromium.ps1
Created registry key for chromium.
Aborting installation for ungoogled-chromium. Ungoogled chromium isn't supported. Please open an issue to add support.
Installed native manifest for librewolf.
Creating registry key for librewolf. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/librewolf.ps1
Created registry key for librewolf.
Installed native manifest for opera.
Creating registry key for opera. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/opera.ps1
Created registry key for opera.
Installed native manifest for brave.
Creating registry key for brave. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/brave.ps1
Created registry key for brave.
Installed native manifest for vivaldi.
Creating registry key for vivaldi. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/vivaldi.ps1
Created registry key for vivaldi.
Aborting installation for chrome-dev. No chrome dev on win32.
Installed native manifest for firefox.
Creating registry key for firefox. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/firefox.ps1
Created registry key for firefox.
Installed native manifest for chrome-canary.
Creating registry key for chrome-canary. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/chrome-canary.ps1
Created registry key for chrome-canary.
Installed native manifest for chrome.
Creating registry key for chrome. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/chrome.ps1
Created registry key for chrome.
Installed native manifest for edge.
Creating registry key for edge. This may take a while. Script: /mnt/c/Users/hwine/AppData/Local/firenvim/edge.ps1
Created registry key for edge.
Press ENTER or type command to continue

You'll notice that the "registry script" is written to /mnt/c/Users/.... While this is the out of the box configuration, many of us configure an alternate root directory as documented here. I.e., my windows directories are under /c/Users/....

The good news is I now have all the examples I need 😉.

Personally, I'd be fine with just documenting this -- anyone technical enough to change their mount preferences should be able to handle creating the files needed to support firenvim.

If you are interested in tackling that issue, there is a utility wslpath that understands finding the full translation process (docs).

glacambre commented 1 year ago

Hi, thanks for the report and for taking the time to dig into this issue yourself, it's always refreshing to see :).

failure to detect windows browsers from arm64 wsl

This must indeed come from the non-default mount path. I didn't know about wslpath, I'll see if I can make that work.

lack of support for non-GA Firefox channels

I'm not sure what this means - the only meaning I can find for "non-GA" would be "non-Google Analytics", but this should have little impact on Firenvim. The only two things that matter for Firenvim are where firefox puts its configuration data (so that Firenvim can detect Firefox is installed) and where to put the native manifest (so that Firefox can run neovim). If your non-GA build installs like a regular Firefox, there shouldn't be any problems (aside from the non-default mount path issue you already identified).

It's not clear what the registry entries should be for firenvim-in-WSL, and I can't inspect a working install due to the first issue.

When firenvim#install() is run under WSL and Firefox is detected on both windows and WSL, Firenvim will create two manifests: one in WSL and one on windows. It will also create a windows registry key pointing to the windows manifest which will enable the firefox installed on windows to run the neovim installed in WSL.

hwine commented 1 year ago

lack of support for non-GA Firefox channels

I'm not sure what this means - the only meaning I can find for "non-GA" would be "non-Google Analytics", but this should have little impact on Firenvim.

My apologies -- by "GA" I meant "Generally Available" -- a term I picked up somewhere to distinguish the-release-everyone-gets from those intended for special audiences. Firefox calls these "channels" and currently has 5 of them (see the options under Which browser would like to download?).

I'm not enough of a Windows person to know what goes where, but each channel appears to have a separate "tree" both in the file system and the registry. I'm experimenting right now with some of that, but I'm programming-by-coincidence and can't cite official sources.

glacambre commented 1 year ago

It looks like the following patch might be enough to fix all of our problems:

diff --git a/autoload/firenvim.vim b/autoload/firenvim.vim
index bd37cfd..a68663a 100644
--- a/autoload/firenvim.vim
+++ b/autoload/firenvim.vim
@@ -83,6 +83,13 @@ function! s:to_wsl_path(path) abort
         if a:path[0] ==# '/'
                 return a:path
         endif
+   if executable('wslpath')
+       try
+           " 0:-2 because we need to remove the \r\n
+           return system(['wslpath', '-a', '-u', a:path])[0:-2]
+       catch
+       endtry
+   endif
         let l:path_components = split(a:path, '\\')
         return join(['/mnt', tolower(path_components[0][0:-2])] + l:path_components[1:-1], '/')
 endfunction

I'll merge it soon.

As for the channels you're talking about, they all store their config in %APPDATA%\Mozilla\Firefox and seem to use the the same registry key, so I believe they should all work without needing any special casing 🤞.

glacambre commented 1 year ago

The patch is now available on master - could you update the Firenvim neovim plugin and attempt to install Firenvim from WSL again?

hwine commented 1 year ago

Looks good to me -- uses my local, AND detects the browsers I have installed.

call firenvim#install(0) output
Installed native manifest for chromium.
Installed native manifest for ungoogled-chromium.
Installed native manifest for librewolf.
No config detected for opera. Skipping.
Installed native manifest for brave.
Installed native manifest for vivaldi.
Installed native manifest for chrome-dev.
Installed native manifest for firefox.
No config detected for chrome-canary. Skipping.
Installed native manifest for chrome.
Installed native manifest for edge.
Installation complete on the wsl side. Performing install on the windows side.
No config detected for chromium. Skipping.
No config detected for ungoogled-chromium. Skipping.
No config detected for librewolf. Skipping.
No config detected for opera. Skipping.
No config detected for brave. Skipping.
No config detected for vivaldi. Skipping.
Aborting installation for chrome-dev. No chrome dev on win32.
Installed native manifest for firefox.
Creating registry key for firefox. This may take a while. Script: /c/Users/hwine/AppData/Local/firenvim/firefox.ps1
Created registry key for firefox.
No config detected for chrome-canary. Skipping.
No config detected for chrome. Skipping.
Installed native manifest for edge.
Creating registry key for edge. This may take a while. Script: /c/Users/hwine/AppData/Local/firenvim/edge.ps1
Created registry key for edge.
Press ENTER or type command to continue

Thanks for a quick fix!