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

bug: external command not found in checkhealth #1599

Closed
3 tasks done
Leeto1970 opened this issue Jul 1, 2024 · 10 comments · Fixed by #1595
Closed
3 tasks done

bug: external command not found in checkhealth #1599

Leeto1970 opened this issue Jul 1, 2024 · 10 comments · Fixed by #1595
Labels
bug Something isn't working

Comments

@Leeto1970
Copy link

Leeto1970 commented Jul 1, 2024

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.11.0-dev-139+ga18652ed6

Operating system/version

windows 10

Describe the bug

when I execute "checkhealth lazy" in nvim with windows git-bash, it show "OK {git} /usr/bin/bash: line 1: git --version: command not found"

Steps To Reproduce

  1. start nvim in git bash
  2. type ":checkhealth lazy"
  3. not show "git --version", but a error. like following picture:
    checkhealth-lazy

Expected Behavior

no error.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
if vim.fn.has('win64') == 1 or vim.fn.has('win32') == 1 then
  vim.opt.shellquote = "\""
  vim.opt.shellcmdflag = "-c"
end
@Leeto1970 Leeto1970 added the bug Something isn't working label Jul 1, 2024
@Leeto1970
Copy link
Author

When I execute ":!git --version" , it's OK
external-command-is-OK-in-x-mode

@folke
Copy link
Owner

folke commented Jul 2, 2024

The only issue here is that it returned OK instead of an ERROR. Just fixed that.

Apart from that, there's something wrong with your installation.
git is on your path (vim.fn.executable), but when trying to run it with vim.fn.system it is not found, so this means you're probably resetting your path in your .bashrc somehow.

@Leeto1970
Copy link
Author

Leeto1970 commented Jul 2, 2024

The only issue here is that it returned OK instead of an ERROR. Just fixed that.

Apart from that, there's something wrong with your installation. git is on your path (vim.fn.executable), but when trying to run it with vim.fn.system it is not found, so this means you're probably resetting your path in your .bashrc somehow.

OK,I will find out my installation problem, thanks for you information.

@Leeto1970
Copy link
Author

@folke Hi,I found that I use lua print(vim.fn.system('"git --version"')), neovim show right result, so maybe should add '' to execute the system command in Windows.
execute_cmd_right

@Leeto1970
Copy link
Author

Leeto1970 commented Jul 15, 2024

add-double-quote
checkhealth-lazy-ok
It's OK for me.

@michaelmelancon
Copy link

I think the issue has to do with whether the vim.fn.system argument is treated as a string or not which determines how/whether it is run in the shell. If it is passed in as {'git', '--version'} instead of 'git --version', it works.

@folke
Copy link
Owner

folke commented Jul 21, 2024

@michaelmelancon yes and that is what we do.
For Op it's the other way around, which means his setup is broken

@michaelmelancon
Copy link

It looks like the version check in health.lua, local version = vim.fn.system(c .. " " .. opts.version) or "", is using string building instead of passing the command and args like so local version = vim.fn.system({c, opts.version}) or "".

@folke
Copy link
Owner

folke commented Jul 22, 2024

I've already changed it. Update your plugins.

@michaelmelancon
Copy link

It is amazing how quick and responsive you are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants