Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lua/config/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ local parser_repos = {

-- this function needs to be updated occasionally, as of 260130, glibc should be at least 2.30
local function get_glibc_version()
local result = vim.fn.system("ldd --version 2>&1 | head -n1")
if vim.v.shell_error ~= 0 then
local result = vim.system({ "ldd", "--version" }, { text = true }):wait()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle missing ldd without aborting startup

On macOS or other systems where ldd is not in PATH, vim.system({ "ldd", "--version" }, ...) throws before :wait() can return, so the result.code check below is never reached. Because get_glibc_version() is called by ts_install() while this module loads, those users now hit a Lua startup error instead of the previous shell pipeline simply producing no parseable glibc version and continuing to the tree-sitter CLI check.

Useful? React with 👍 / 👎.

if result.code ~= 0 then
return nil
end
local version = result:match("(%d+%.%d+)%s*$") or result:match("GLIBC (%d+%.%d+)")
if version then
return tonumber(version)
end
return nil
local output = result.stdout ~= "" and result.stdout or result.stderr
local first_line = output:match("^([^\n]*)")
local version = first_line:match("GLIBC (%d+%.%d+)") or first_line:match("(%d+%.%d+)%s*$")
return version and tonumber(version) or nil
end

local function has_tree_sitter_cli()
Expand Down
Loading