glacambre / firenvim

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

fix: run scripts in noninteractive shell (#1547) #1577

Closed xudyang1 closed 8 months ago

xudyang1 commented 8 months ago

Firenvim on Windows relys on powershell scripts to run registry keys installation and uninstallation. Here are the codes:

https://github.com/glacambre/firenvim/blob/8c6c00aae7e5762cbcb4cd0df5848e959c4a9572/autoload/firenvim.vim#L890

https://github.com/glacambre/firenvim/blob/8c6c00aae7e5762cbcb4cd0df5848e959c4a9572/autoload/firenvim.vim#L958

During debugging, I add echo o right after calling the system function, which then shows error

Cannot load PSReadline module.  Console is running without PSReadline.

But weirdly, v:shell_error is still 0. PSReadline is a module usually installed for interactive prompt usage. Powershell.exe provides option -NonInterative for running automated scripts in non-interactive shell. Adding the -NonInteractive option fixes #1547 as the scripts run successfully without error.

[!NOTE] This pull request only fixes firenvim installation on Windows host and WSL2 environment. Uninstallation scripts run successfully when running firenvim on the host (%LOCALAPPDATA/firenvim/* files and corresponding registry keys are removed); run firenvim#uninstall() on WSL side only removes the binary in WSL (stdpath('data')/firenvim in WSL or $HOME/.local/share/firenvim/firenvim)

A separate issue #1576 tracks the uninstallation bug on WSL side

glacambre commented 8 months ago

Wow, great debugging skills, thank you for taking the time to open a PR! :)