You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Amazon Linux 2安装SDKMan遇GLIBC_2.28未找到错误求助

问题

在Amazon Linux 2 AMI(必须使用官方认证/打补丁镜像,无其他选择)上安装SDKMan,执行以下步骤无报错:

sudo curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

但运行sdk version时出现错误:

/home/ec2-user/.sdkman/libexec/version: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /home/ec2-user/.sdkman/libexec/version)

系统GLIBC版本为2.26,无法通过yum升级到2.28(会损坏系统),且找不到SDKMan旧版本,求解决办法。

系统GLIBC信息:

[ec2-user@ip-xxx-xxx-vvv-ssss ~]$ yum info glibc
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
224 packages excluded due to repository priority protections
Installed Packages
Name        : glibc
Arch        : x86_64
Version     : 2.26
Release     : 63.amzn2
Size        : 13 M
Repo        : installed
Summary     : The GNU libc libraries
URL         : http://www.gnu.org/software/glibc/
License     : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Description : The glibc package contains standard libraries which are used by
            : multiple programs on the system. In order to save disk space and
            : memory, as well as to make upgrading easier, common system code is
            : kept in one place and shared between programs. This particular package
            : contains the most important sets of shared libraries: the standard C
            : library and the standard math library. Without these two libraries, a
            : Linux system will not function.

Available Packages
Name        : glibc
Arch        : i686
Version     : 2.26
Release     : 63.amzn2
Size        : 4.1 M
Repo        : amzn2-core/2/x86_64
Summary     : The GNU libc libraries
URL         : http://www.gnu.org/software/glibc/
License     : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Description : The glibc package contains standard libraries which are used by
            : multiple programs on the system. In order to save disk space and
            : memory, as well as to make upgrading easier, common system code is
            : kept in one place and shared between programs. This particular package
            : contains the most important sets of shared libraries: the standard C
            : library and the standard math library. Without these two libraries, a
            : Linux system will not function.
解决方法
  • 安装兼容旧GLIBC的SDKMan历史版本
    先查询SDKMan的历史版本列表:

    curl -s https://api.sdkman.io/2/candidates/sdkman/versions | jq .
    

    选择一个发布时间早于GLIBC 2.28的版本(比如5.12.0及之前),卸载当前SDKMan后手动安装指定版本:

    # 卸载现有SDKMan
    rm -rf ~/.sdkman
    # 替换$VERSION为找到的兼容版本号,例如5.12.0
    curl -s "https://get.sdkman.io/$VERSION" | bash
    source "$HOME/.sdkman/bin/sdkman-init.sh"
    
  • 本地编译GLIBC 2.28,临时指定运行时库
    不替换系统GLIBC,编译本地版本供SDKMan单独使用:

    # 安装编译依赖
    sudo yum install -y gcc make bison
    # 创建编译目录并下载源码
    mkdir -p ~/glibc-build && cd ~/glibc-build
    curl -O https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
    tar xf glibc-2.28.tar.gz && cd glibc-2.28
    # 配置编译路径(安装到用户目录下的local-glibc)
    mkdir build && cd build
    ../configure --prefix=$HOME/local-glibc --disable-sanity-checks
    # 编译安装
    make -j$(nproc)
    make install
    

    为SDKMan添加别名,自动加载本地GLIBC:

    echo 'alias sdk="LD_LIBRARY_PATH=$HOME/local-glibc/lib:$HOME/local-glibc/lib64 sdk"' >> ~/.bashrc
    source ~/.bashrc
    

    之后直接运行sdk version即可正常使用。

  • 手动管理候选工具,绕过SDKMan二进制依赖
    直接下载JDK、Gradle等工具到~/.sdkman/candidates对应目录,手动配置环境变量,无需依赖SDKMan的二进制执行文件,例如:

    # 下载JDK 17到候选目录
    mkdir -p ~/.sdkman/candidates/java/17.0.9
    curl -L https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.9%2B9/OpenJDK17U-jdk_x64_linux_hotspot_17.0.9_9.tar.gz | tar -xz -C ~/.sdkman/candidates/java/17.0.9 --strip-components=1
    # 配置环境变量
    echo 'export JAVA_HOME=$HOME/.sdkman/candidates/java/17.0.9' >> ~/.bashrc
    echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
    source ~/.bashrc
    

内容的提问来源于stack exchange,提问作者Pierre

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 02:02:25