首页 > 解决方案 > 在新推送的 docker image ruby​​:2.7.4-alpine3.13 上安装一些 ruby​​gems 时“找不到 -lucontext”

问题描述

我无法再安装 Rubygemsbyebug和最后一天推送racc的图像。ruby:2.7.4-alpine3.13似乎某些东西已被删除或移动。

重现:

docker pull ruby:2.7.4-alpine3.13
2.7.4-alpine3.13: Pulling from library/ruby
Digest: sha256:89b589e1b6b334ed7af93da3d4c75dca5beef8f1a844594c3a865bc6c4f5b96e
Status: Image is up to date for ruby:2.7.4-alpine3.13

docker run --rm -it --entrypoint /bin/sh ruby@sha256:89b589e1b6b334ed7af93da3d4c75dca5beef8f1a844594c3a865bc6c4f5b96e
apk --no-cache add "build-base>=0.5"
gem install byebug

给我:

Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.

在记录下来之后,我得到:

current directory: /usr/local/bundle/gems/byebug-11.1.3/ext/byebug
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.7.0 -r ./siteconf20211027-12-7c6k46.rb extconf.rb
creating Makefile

current directory: /usr/local/bundle/gems/byebug-11.1.3/ext/byebug
make "DESTDIR=" clean

current directory: /usr/local/bundle/gems/byebug-11.1.3/ext/byebug
make "DESTDIR="
compiling breakpoint.c
compiling byebug.c
compiling context.c
compiling locker.c
compiling threads.c
linking shared-object byebug/byebug.so
/usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lucontext
collect2: error: ld returned 1 exit status
make: *** [Makefile:262: byebug.so] Error 1

寻找我们得到的头文件:

find . -name ucontext.h
./usr/include/asm/ucontext.h
./usr/include/asm-generic/ucontext.h
./usr/include/sys/ucontext.h
./usr/include/ucontext.h

byebug gem 的安装使用摘要来定义曾经ruby:2.7.4-alpine3.13在 2021 年 10 月 19 日(ruby@sha256:ace3785b1a5eb95d08285f8741e3dc1c481c479a271d54e37b8e45a7106d86c6

当我find . -name ucontext.h在工作映像上运行时,文件位于同一位置。

有人对如何使它工作有任何想法吗?

标签: rubylinuxdockeralpine

解决方案


我遇到了同样的问题。似乎这是由这个提交引起的,我手动添加了libucontext-devAlpine 包并将命令包含export LIBS='-lucontext'到我的 Dockerfile 中,并且我的构建再次开始工作。


推荐阅读