Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby gem fails to install on Alpine #394

Open
wkirby opened this issue Nov 8, 2024 · 2 comments
Open

Ruby gem fails to install on Alpine #394

wkirby opened this issue Nov 8, 2024 · 2 comments

Comments

@wkirby
Copy link

wkirby commented Nov 8, 2024

I'm running a ruby alpine docker container (ruby:3.3-alpine3.19). I have installed the packages alpine-sdk, ruby-dev and gcompat, which are usually enough to build any gem that does not have pre-built binaries.

Running gem install css_inline results in the following output:

Building native extensions. This could take a while...
ERROR:  Error installing css_inline:
	ERROR: Failed to build gem native extension.

    current directory: /bundle/gems/css_inline-0.14.1/ext/css_inline
/usr/local/bin/ruby extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include=${opt-dir}/include
	--without-opt-include
	--with-opt-lib=${opt-dir}/lib
	--without-opt-lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/local/bin/$(RUBY_BASE_NAME)
<internal:/usr/local/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require': cannot load such file -- rb_sys/mkmf (LoadError)
	from <internal:/usr/local/lib/ruby/site_ruby/3.3.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from extconf.rb:2:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /bundle/gems/css_inline-0.14.1 for inspection.
Results logged to /bundle/extensions/aarch64-linux-musl/3.3.0/css_inline-0.14.1/gem_make.out

Any guidance on missing dependencies would be appreciated, as would prebuilt binaries aarch64-linux-musl.

@Stranger6667
Copy link
Owner

Hi! I think a Rust compiler might be missing there. I am going to take a look at magnus docs in this regard, maybe I've missed something.
I'd be happy to build aarch64-linux-musl for Ruby as a part of the release artifact set.

@wkirby
Copy link
Author

wkirby commented Nov 8, 2024

@Stranger6667 thanks for the fast response!

Tried isntalling clang & lld, then installing rust itself. cargo --version now outputs:

cargo 1.82.0 (8f40fc59f 2024-08-21)

Unfortunately, this still results in the same error message as above.

Here's a minimal Dockerfile which allows a repro of the issue:

FROM public.ecr.aws/docker/library/ruby:3.3-alpine3.19 AS runner

ENV APP_HOME="/app"
ENV BUNDLE_BIN="/bundle/bin"
ENV DEBIAN_FRONTEND="noninteractive"
ENV BUNDLE_BUILD__SASSC="--disable-march-tune-native"
ENV BUNDLE_JOBS="5"
ENV BUNDLE_PATH="/bundle"
ENV GEM_HOME="/bundle"
ENV BUNDLE_GEMFILE="$APP_HOME/Gemfile"
ENV PATH="${BUNDLE_BIN}:${PATH}"

WORKDIR $APP_HOME

# Update Gems first...only re-do this when bundler version changes.
# If we need to force a gem update we'll have to `--no-cache` or add a file we can copy in
RUN gem update --system && gem install bundler:2.5.21

RUN apk add --update --no-cache \
    alpine-sdk \
    curl \
    bash \
    gcompat

If you save that to a directory as Dockerfile, then you should be able to run:

docker run -it $(docker build -q .) bash

That should drop you into the container in a minimal reproduction of my environment.

Then

gem install css_inline

And observe the error I'm getting.

Ultimately, though, it shouldn't really matter. If you're able to build/distribute the binaries for aarch64-linux-musl the whole thing is probably moot.

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

No branches or pull requests

2 participants