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] Error reading process output on windows: EBADF: bad file descriptor #26

Open
NavyD opened this issue Feb 23, 2025 · 0 comments
Open
Assignees

Comments

@NavyD
Copy link

NavyD commented Feb 23, 2025

NeoVim Version

NVIM v0.10.4
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Describe the bug

Running a command with nio.process.run on windows does not read stdout:

local text = "hello"
local exe = "echo"
local nio = require("nio")
nio.run(function()
	local nio_proc = require("nio").process
	local echo_proc, echo_err = nio_proc.run({
		cmd = exe,
		args = { text },
	})
	local echo_output, echo_read_err = echo_proc.stdout.read()
	assert(echo_read_err == nil, "read err: " .. echo_read_err)
end)

Image

To Reproduce
Please provide a minimal init.lua to reproduce which can be run as the following:

nvim --clean -u minimal.lua

You can edit the following example file to include your adapters and other required setup.

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{
			"nvim-neotest/nvim-nio",
			version = "v1.10.1",
			lazy = false,
		},
	},
})

local text = "hello"
local exe = "echo"

local echo_out = vim.system({ exe, text }, { text = true }):wait()
-- vim.system({ "echo", "hello" }, { text = true }):wait()
assert(echo_out.code == 0)
assert(echo_out.stdout)
assert(vim.trim(echo_out.stdout) == text, "stdout: " .. echo_out.stdout .. " != text: " .. text)

local nio = require("nio")
nio.run(function()
	local nio_proc = require("nio").process
	local echo_proc, echo_err = nio_proc.run({
		cmd = exe,
		args = { text },
	})
	assert(echo_proc ~= nil)
	assert(echo_proc.result(true) == 0)
	local echo_output, echo_read_err = echo_proc.stdout.read()
    -- FIXME: read error
	assert(echo_read_err == nil, "read err: " .. echo_read_err)
	-- assert(echo_output and echo_output ~= "", "echo output is empty")
end)

Steps to reproduce the behavior:

mkdir -Force "$env:TEMP\test-neovim-nio"
cd "$env:TEMP\test-neovim-nio"
nvim --clean -u minimal.lua

Please provide example test files to reproduce.

Expected behavior

stdout.read() should return the output of the command

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

2 participants