首页 > 解决方案 > 带有 C 扩展的 Ruby gem 不在 Ubuntu 中构建

问题描述

我正在尝试基于DockerfileHeroku 的新heroku/heroku:18映像(使用 Ubuntu 18.04)并遇到一些我在他们非常旧的heroku/cedar:14基本映像中没有的问题,我相信由于他们有不同的预安装包。(我将基础映像更新为heroku/heroku:18因为我想使用webpackergem,并且在 Cedar-14 中我得到了:Webpacker requires Node.js >= 6.0.0 and you are using 0.10.25。如果有一种简单的方法可以在旧的基础映像中安装更新的节点,我很乐意听到它!)

我的问题是没有任何带有 C 扩展名的 gem(如puma, pg, msgpack, 等)使用这个新的基础 Docker 映像成功安装。错误消息因宝石而异,但通常都说:

The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

有类似问题的各种 GitHub 问题让我尝试过:

这些解决方案都不能解决问题。

作为参考,这里是我的相关部分Dockerfile

FROM heroku/heroku:18

RUN apt-get update && apt-get install -y nodejs --no-recommends

RUN (mkdir -p /ruby && cd /ruby && curl https://s3-external-1.amazonaws.com/heroku-buildpack-ruby/heroku-18/ruby-2.5.0.tgz -s -o - | tar xzf - --no-same-owner)

ENV GEM_HOME=/ruby/gems GEM_PATH=/ruby/gems

RUN gem install bundler

RUN bundle install

标签: rubyubuntudockerherokuubuntu-18.04

解决方案


推荐阅读