-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
s:get_runtime_dir_path function returns garbage when WSLg is activated on Windows 11 #1458
Comments
Thanks for opening this issue. Can you confirm that I understood everything correctly?
|
Yes, correct. |
I'm not sure how to fix this. The source of the issue is to_windows_path: firenvim/autoload/firenvim.vim Lines 73 to 79 in eeaddd0
There's an expectation that the path is of the form Do you know how to figure out what windows directory a wsl mount point is pointing to? |
No, that is the default mountpoint for wslg. AFAIK it is a network share to allow wslg to do easier x11 forwarding by moving the sockets to that directory..
It can be accessed from windows via a network drive, not directly since it is a virtual drive. $ wslpath -w /mnt/wslg/runtime-dir/
\\wsl.localhost\NixOS\mnt\wslg\runtime-dir |
but cmd cannot cd into that directoy. We could use pushd but then WSL cannot translate the path. To where should that path normally point in WSL? Something like?
|
The following patch should solve everything: diff --git a/autoload/firenvim.vim b/autoload/firenvim.vim
index e658532..94cd4e0 100644
--- a/autoload/firenvim.vim
+++ b/autoload/firenvim.vim
@@ -590,6 +590,14 @@ function! s:get_executable_content(data_dir, prolog) abort
\"let g:firenvim_c=stdioopen({'on_stdin':{i,d,e->g:Firenvim_oi(i,d,e)},'on_print':{t->g:Firenvim_oo(t)}})".
\'"'
endif
+ if s:is_wsl
+ " Get path of firenvim script on the linux side, execute that
+ " from the windows batch script
+ let s:is_wsl = v:false
+ let l:script_path = s:get_firenvim_script_path()
+ let s:is_wsl = v:true
+ return "@echo off\r\nwsl \"" . l:script_path . '"'
+ endif
if has('win32') || s:is_wsl
let l:wsl_prefix = ''
if s:is_wsl
@@ -752,6 +760,10 @@ function! s:get_browser_configuration() abort
endfunction
+function! s:get_firenvim_script_path()
+ return s:build_path([s:get_data_dir_path(), s:get_executable_name()])
+endfunction
+
" At first, is_wsl is set to false, even on WSL. This lets us install firenvim
" on the wsl side, in case people want to use a wsl browser.
" Then, we set is_wsl to true if we're on wsl and launch firenvim#install
@@ -795,14 +807,10 @@ function! firenvim#install(...) abort
endif
endif
- " Decide where the script responsible for starting neovim should be
- let l:data_dir = s:get_data_dir_path()
- let l:execute_nvim_path = s:build_path([l:data_dir, s:get_executable_name()])
-
- " Write said script to said path
+ let l:execute_nvim_path = s:get_firenvim_script_path()
let l:execute_nvim = s:get_executable_content(s:get_runtime_dir_path(), l:script_prolog)
- call s:maybe_execute('mkdir', l:data_dir, 'p', 0700)
+ call s:maybe_execute('mkdir', s:get_data_dir_path(), 'p', 0700)
if s:is_wsl
let l:execute_nvim_path = s:to_wsl_path(l:execute_nvim_path)
endif I'll open a PR and see if anything breaks. |
CI was okay with the change, so I merged it. Could you update the firenvim neovim plugin to master/f6ef690 , run |
Inside of WSL things are now working like a charm when reinstalling without any other changes
but from the cmd it is still not working and the prompt is staying open:
When adding the snipped from #1460 (comment) then the prompt closes instead with no output. The browser extension still show the same error I tried restarting chrome but that also did not fix things. |
Do you have multiple wsl machines installed? If yes, please try to install Firenvim in all of them - windows might be using the wrong wsl VM. Also, if you go to |
When I only start wsl then NixOS is started which is the default WSL instance. The first two messages where errors, the last two only warnings.
|
Everything looks as expected here... Do you have a windows registry key named Also, could you add something like |
Yes,
I tried that and when just executing |
Did you look at the content of |
When executing inside of WSL all the temporary echos I placed in the file where written into |
Okay, thanks for trying this. What happens if you remove |
Nope
Nothing is in it. I think the problem is somehow the piping. cmd has pipes, too but they are very different to unix pipes and I am not sure if you can even pipe into WSL like you are doing. |
Piping does not come into play when running firenvim.bat from the browser, stdin/stdout are inherited by whatever command is ran by the batch script, and neovim inherints said stdin/stdout when In general, there is no fundamental issue with how Firenvim currently works: Firenvim is known to work with both WSL (#839, #918, #969, #1198) and NixOS (#175, #365, #422, #960).
You are very likely to need the same configuration in your WSL machine then. Could you try to make your WSL-nixos configuration match your linux-nixos configuration and try again? |
What I tried to do
Run the post install script via
call firenvim#install(0)
in my WSL with NixOS on Windows 11 with WSLg enabled.What happened
Because
$XDG_RUNTIME_DIR
is set to/mnt/wslg/runtime-dir
the header of the generated bat script contained the following:which is obvious garbage and wont work.
When unsetting XDG_RUNTIME_DIR before opening neovim and cleaning up the windows file the installation went through smoothly.
The text was updated successfully, but these errors were encountered: