4

I am trying to run terminal commands from neovim. I launched nvim from git bash. But when I run :!ls I get the error

: /usr/bin/bash: /s: No such file or directory

shell returned 127

I searched the internet, I couldn't find the solution. Can anybody help me with this??

Specs: I installed both git and neovim from the websites. OS: Windows 11.

Running bash commands from neovim would be a useful feature that improves my productivity.

enter image description here

2 Answers 2

4

There are actually a same issue on Neovim’s GitHub.

Try add set shellcmdflag=-c to your config file.

Sign up to request clarification or add additional context in comments.

1 Comment

It works, but not always, as a temporary solution can be used in init.vim :let &shell = '"C:\WINDOWS\system32\cmd.exe"'
0

I had the same problem and solving it required recreating a couple of different problems in the process. I used a couple of different approaches together but what worked for me finally was adding this to the init.lua file.

if (os.getenv("SHELL") and os.getenv("SHELL"):find("bash")) then
    --Configuring gitbash as THE shell
    vim.o.shell = [["C:/Program Files/Git/usr/bin/bash.exe"]]
    vim.o.shellcmdflag = "-c"
    vim.o.shellredir = ">%s 2>&1"
    vim.o.shellquote = ""
    vim.o.shellxescape = ""
    vim.env.TMP = "/tmp"
    vim.o.shellxquote = ""
    vim.o.shellpipe = "2>&1| tee"
end

Also, it may require finding your bash.exe in a different location.

Best

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.