Skip to content

fix(path): use os.getenv instead of vim.env in PathLib:expand - #296

Merged
dlyongemallo merged 1 commit into
dlyongemallo:mainfrom
napisani:main
Jul 15, 2026
Merged

fix(path): use os.getenv instead of vim.env in PathLib:expand#296
dlyongemallo merged 1 commit into
dlyongemallo:mainfrom
napisani:main

Conversation

@napisani

Copy link
Copy Markdown
  • PathLib:expand (and therefore PathLib:absolute) read environment variables via vim.env[env_var], whose __index is backed by
    Vimscript's getenv() — a call that requires Neovim's main/textlock context.
  • PathLib:absolute is diffview's general-purpose path-resolution helper and gets called while processing paths returned from git
    subprocess output, which runs inside libuv job/process callbacks (fast-event context). On Neovim 0.10+ this throws an E5560-class
    error ("Vimscript function must not be called in a lua loop callback") for any path containing a literal $VAR segment.
  • Replaced vim.env[env_var] with os.getenv(env_var) — a plain Lua/C call with no dependency on the main loop, safe from any context,
    and a drop-in equivalent for this read-only lookup.

vim.env's __index is backed by Vimscript's getenv(), which requires
Neovim's main/textlock context. PathLib:expand (via PathLib:absolute)
is called while processing paths from git subprocess output, which
happens inside libuv fast-event callbacks on Neovim 0.10+, throwing an
E5560-class error. os.getenv is a plain Lua/C call safe from any
context.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dlyongemallo
dlyongemallo merged commit 9596bd4 into dlyongemallo:main Jul 15, 2026
7 of 8 checks passed
@dlyongemallo

Copy link
Copy Markdown
Owner

Thanks @napisani for catching this.

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

Successfully merging this pull request may close these issues.

2 participants