Repository navigation
luai: expose lines() on the Windows io.popen handle - #751
Merged
Merged
Conversation
The Windows io.popen override added in version-fox#712 returns a table with read, write and close only. gopher-lua's file and process handles also expose lines(), so plugin code that iterates command output with `for line in handle:lines()` fails with "attempt to call a non-function object" before reading anything. vfox-python's PostInstall hits this while enumerating its installer packages, which breaks `vfox install python` on Windows. Add a lines() method that returns an iterator backed by the same buffered reader as read("*l"): one line without its trailing CR/LF per call, nil at EOF, and an error on the write-only mode. This restores the contract the override was meant to preserve. Fixes version-fox#749
bytemain
approved these changes
Nov 8, 2026
aooohan
approved these changes
Nov 9, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #751 +/- ##
==========================================
- Coverage 56.29% 56.21% -0.08%
==========================================
Files 115 115
Lines 8564 8576 +12
==========================================
Hits 4821 4821
- Misses 3279 3291 +12
Partials 464 464 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thanks for the first contribution ;) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a
lines()method to the Lua table returned by the Windowsio.popen()override ininternal/plugin/luai/exec.go.Why
Plugins on Windows cannot iterate command output with the standard Lua idiom:
The override installs its own handle table with only
read,writeandclose, solisting:linesis nil and the call fails withattempt to call a non-function object. Every plugin that shells out and parses output line by line is affected. The concrete breakage reported in #749 is vfox-python'sPostInstall, which dies while enumerating its downloaded MSI packages, sovfox install python@<version>cannot complete on Windows.gopher-lua's own file and process handles (iolib.go
fileMethods) exposelines, and so did nativeio.popenbefore the Windows override was introduced in #712. This restores that contract.Reproduction
With the Python plugin installed, on Windows:
vfox install python@3.14.10A minimal version of the same failure, run against the base commit:
The same handle's
read("*a")works at the base commit (returns"hello\r\n"), so the child process and pipe are fine — the method is simply missing.Root cause
internal/plugin/luai/exec.go:132(base3682fe8) builds the handle table:lineswas never registered. The file was created in #712 (git show 5a54885 --statshowsinternal/plugin/luai/exec.go | 265 +++++), replacing the native gopher-lua handle, so this is an API gap introduced by that override rather than a plugin misuse.Verification
TestPopenHandleLinesIteratesLines: fails on the base commit withattempt to call a non-function object, passes with the change. The iterator yieldsalpha,beta,gammafrom a realcmd.exerun, which also proves CRLF is stripped.TestPopenHandleLinesRejectsWriteMode:lines()on a write-mode handle raisescannot read from a write-only popen handle, matching the existingreadmethod.go test ./... -count=1, twice): all packages pass, 31s and 27s.internal/shared/printer's interactiveTestSelect_Showis skipped because it blocks on keyboard input in this environment; it fails the same way on the unmodified base commit.gofmt -landgo vet ./internal/plugin/luai/are clean.close()(raises instead of silently ending).Risk
The change is additive and only affects the Windows override; macOS and Linux keep gopher-lua's native
io.popen. Format arguments are not interpreted, matching gopher-lua'sfile:lines(). The globalio.lines(filename)function is untouched.