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

"diff" is not exectuable (Windows | Neovim nightly) #168

Closed
ninbura opened this issue Jan 15, 2024 · 4 comments
Closed

"diff" is not exectuable (Windows | Neovim nightly) #168

ninbura opened this issue Jan 15, 2024 · 4 comments

Comments

@ninbura
Copy link

ninbura commented Jan 15, 2024

issue

When triggering UndotreeToggle in Neovim nightly on Windows I get the following error:

E5108: Error executing lua: function undotree#UndotreeToggle[11]..<SNR>45_new[2]..41, line 6: Vim(echoerr):"diff" is not executable.
stack traceback:                                                                                                                                                                                                                                                                                                                                                                                  [C]: at 0x7ff649ab50c0

This only happens on Windows when running running the nightly build of Neovim. I don't get this error when running the same configuration via Neovim stable (v0.9.5) on Windows, or Neovim stable/nightly on Ubuntu.

I see that others have mentioned this error in another issue. I've also seen discussion of this issue on the neovim subreddit. But their solution is not applicable in this case, as I set PowerShell 7 as my terminal (:h powershell); where diff is a valid command. As mentioned before, undotree works fine using diff in Neovim stable on Windows via the same configuration.

setting powershell as default shell

if(vim.loop.os_uname().sysname == "Windows_NT")
  then
    vim.opt.shell = vim.fn.executable "pwsh" and "pwsh" or "powershell"
    vim.opt.shellcmdflag = "-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;"
    vim.opt.shellredir = "2>&1 | %%{ '$_' } | Out-File %s; exit $LastExitCode"
    vim.opt.shellpipe = "2>&1 | %%{ '$_' } | tee %s; exit $LastExitCode"
    vim.opt.shellquote = ""
    vim.opt.shellxquote = ""
  end

lazy config

return {
  "mbbill/undotree",
  keys = {
    {
      "<leader>u",
      vim.cmd.UndotreeToggle,
      desc = "toggle undotree view"
    }
  }
}

system info

# windows os build
22631.3007

# neovim version
v0.10.0-dev-2074+g786089013
@ninbura ninbura changed the title "diff" is not exectuable (Windows |) "diff" is not exectuable (Windows | Neovim nightly) Jan 15, 2024
@mbbill
Copy link
Owner

mbbill commented Jan 17, 2024

the plugin requires diff.exe for the diff panel to work. If you don't have the tool under %PATH% you may simply turn off the diff panel by default. Usually the diff.exe comes with the official vim installation, but I'm not sure about neovim. It's fairly easy to just borrow the exe if needed.

@ninbura
Copy link
Author

ninbura commented Jan 17, 2024

Guess I was just trying to avoid installing another application to get my configuration working remotely. It seems based on Vim's license I can just host their diff.exe myself and pull it to a consistent location.

I guess Neovim stable accounts for diff.exe somehow. Whatever the case, after adding diff.exe to my PATH environment variable I don't get errors in Neovim nightly.

@ninbura ninbura closed this as completed Jan 17, 2024
@samisalreadytaken
Copy link
Contributor

diff.exe was removed in nvim releases here neovim/neovim#22802.

To fix this, either put the latest diff.exe release in your vim bin directory

curl -LO https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/diff.exe

or direct the command to WSL with a script like this

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

REM Expects 2 parameters that are full Windows paths `DRIVE:PATH`
REM Converts drive letter to lower case, fixes path separators and checks /mnt/drive/path on WSL

SET ARG1=%~1
SET ARG2=%~2

SET DRIVE1=%ARG1:~0,1%
SET PATH1=%ARG1:~2%

SET DRIVE2=%ARG2:~0,1%
SET PATH2=%ARG2:~2%

SET PATH1=!PATH1:\=/!
SET PATH2=!PATH2:\=/!

for %%C IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO (
	SET DRIVE1=!DRIVE1:%%C=%%C!
	SET DRIVE2=!DRIVE2:%%C=%%C!
)

wsl -e diff "/mnt/%DRIVE1%%PATH1%" "/mnt/%DRIVE2%%PATH2%"

let g:undotree_DiffCommand="diff" where diff.bat lives in your PATH. Naming this script to anything else requires #170.

@inaciorafael
Copy link

Here is my solution on windows

  • Create and download diff.exe
    cd your_nvim_path
    mdkir bin
    cd bin
    curl -LO https://github.com/neovim/deps/raw/21c5e8bdda33521a6ed497b315e03265a2785cbc/opt/diff.exe

Configure diff.exe in your options

-- my_nvim_path/lua/options.lua
if vim.fn.has "win32" == 1 then -- only windows
  vim.g.undotree_DiffCommand = "my_nvim_path/lua/bin/diff.exe"
end

This worked for me!

bozhidarv pushed a commit to bozhidarv/nvim-conf that referenced this issue Sep 4, 2024
for more info on the solution and why it is necessary: mbbill/undotree#168
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

4 participants