Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

The lib_c_type parameter in foojay.io API requests was hardcoded to glibc, causing JDK downloads to fail on Alpine and other musl-based Linux distributions.

Changes

  • Added detect_lib_c_type() function that runs ldd --version and checks for "musl" in the output
  • Returns "musl" if detected, defaults to "glibc" otherwise
  • Replaces hardcoded lib_c_type = "glibc" with dynamic detection
local function detect_lib_c_type()
    local handle = io.popen("ldd --version 2>&1")
    if handle then
        local result = handle:read("*a")
        handle:close()
        if result and result:lower():find("musl") then
            return "musl"
        end
    end
    return "glibc"
end

API requests will now use the correct lib_c_type parameter based on the system's libc:

  • Alpine/musl: lib_c_type=musl
  • Ubuntu/Debian/CentOS: lib_c_type=glibc
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] 支持检测当前系统使用的 libc 信息并添加到 foojay 的请求参数中</issue_title>
<issue_description>
请求 https://api.foojay.io/disco/v3.0/packages/jdks 的时候 lib_c_type 参数现在默认为 glibc (#14)

https://api.foojay.io/disco/v3.0/packages/jdks?version=17.0.11%2B9&distribution=temurin&architecture=amd64&archive_type=tar.gz&operating_system=linux&release_status=ga&latest=available&lib_c_type=glibc

在 alpine 等系统上,它们使用的是 musl,那么参数就要变:

https://api.foojay.io/disco/v3.0/packages/jdks?version=17.0.11%2B9&distribution=temurin&architecture=amd64&archive_type=tar.gz&operating_system=linux&release_status=ga&latest=available&lib_c_type=musl
```</issue_description>

<agent_instructions>lua has os.execute, can use command to detect arch in linux</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@bytemain</author><body>
js 的实现:https://github.com/lovell/detect-libc</body></comment_new>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: bytemain <13938334+bytemain@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for detecting current system libc type Add libc detection for musl vs glibc on Linux Jan 18, 2026
Copilot AI requested a review from bytemain January 18, 2026 19:16
@bytemain bytemain marked this pull request as ready for review January 18, 2026 19:17
@bytemain bytemain merged commit 604db97 into main Jan 18, 2026
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.

[Feature] 支持检测当前系统使用的 libc 信息并添加到 foojay 的请求参数中

2 participants