glacambre / firenvim

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

Debugging firenvim script challenges #1483

Closed hwine closed 1 year ago

hwine commented 1 year ago

I'm having mixed luck with actually running firenvim from win11 Firefox, when the supporting nvim is located in WSL. (remaining issue from #1481.)

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 🤞.

Originally posted by @glacambre in https://github.com/glacambre/firenvim/issues/1481#issuecomment-1369150598

While all the scripts, appear to be correct, both: a) it's not working, and b) the "test the script" debug process doesn't work as documented.

I get no output to the terminal when invoking the script as shown. This is true even when I stay completely inside of WSL, where the extension works fine with with Firefox-in-WSL. I am assuming getting this to work "as advertised" is my next step in debugging why it's still not working for me from Firefox-in-Win11.

Complete run:

❯ echo 'abcde{}' | $HOME/.local/share/firenvim/firenvim

~
❯

Per the docs, I expected JSON output, but there is none.

What am I not understanding?

glacambre commented 1 year ago

Can you edit $HOME/.local/share/firenvim/firenvim, insert echo LINENUMBEROFTHISILINE >> /tmp/log on every other line, run it from WSL and check /tmp/log to see what line the scripts stops executing on? I expect it'll be the exec one, but let's make sure.

If execution indeed stops on the exec line, try removing ,'on_print':{t->g:Firenvim_oo(t)} from the exec line and running the script from WSL again - does anything change?

hwine commented 1 year ago

to see what line the scripts stops executing on? I expect it'll be the exec one, but let's make sure.

To be clear, the script does not stop execution -- it:

Can you edit $HOME/.local/share/firenvim/firenvim, insert echo LINENUMBEROFTHISILINE >> /tmp/log on every other line, run it from WSL and check /tmp/log

I did it the lazy way: echo 'abcde{}' | bash -ex ~/.local/share/firenvim/firenvim ; echo -e "\nexit status: ${PIPESTATUS[@]}" which showed execution of all statements, and no failures.

If execution indeed stops on the exec line, try removing ,'on_print':{t->g:Firenvim_oo(t)} from the exec line and running the script from WSL again - does anything change?

Ah, interesting - yes, the lua error re-appears:

+ exec /usr/bin/nvim --headless --cmd 'let g:firenvim_i=[]|let g:firenvim_o=[]|let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)}|let g:Firenvim_oo={t->add(g:firenvim_o,t)}|let g:firenvim_c=stdioopen({'\''on_stdin'\'':{i,d,e->g:Firenvim_oi(i,d,e)}})' --cmd 'let g:started_by_firenvim = v:true' -c 'try|call firenvim#run()|catch|call chansend(g:firenvim_c,["f\n\n\n"..json_encode({"messages":["Your plugin manager did not load the Firenvim plugin for neovim."]+g:firenvim_o,"version":"0.0.0"})])|call chansend(2,["Firenvim not in rtp:"..&rtp])|qall!|endtry'
Error detected while processing function <lambda>3[1]..OnStdin[34]..WriteStdout:
line    5:
E5108: Error executing lua [string "luaeval()"]:1: attempt to index global 'bit' (a nil value)
stack traceback:
        [string "luaeval()"]:1: in main chunk
exit status: 0 0

Let me get a decent build of Neovim on my box, and see what happens.

glacambre commented 1 year ago

Oof, this is annoying, I would have expected https://github.com/glacambre/firenvim/pull/1436 to catch this kind of issue. Thanks for the report.

glacambre commented 1 year ago

1436 not catching this kind of error was actually perfectly normal - it only caught errors in firenvim#run, not the ones in the callbacks firenvim#run creates. This is fixed now, every message should be logged to stderr, so I'll close this issue.

Don't hesitate to ask more questions if you still need help setting up Firenvim on your computer though :)