Shravan Ramamurthy
Shravan Ramamurthy

Reputation: 4096

`Gem::Ext::BuildError: ERROR: Failed to build gem native extension` error while bundle install in alpine-3.7 docker image

I have created a docker image using alpine-3.7 and ruby-2.5 (bundler-2.1.2). While installing the ruby gems, using bundle install, I am getting the below error.

Fetching jaro_winkler 1.5.2
Installing jaro_winkler 1.5.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
An error occurred while installing jaro_winkler (1.5.2), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.2' --source 'https://testrepos.net/api/gems/rubygems/'` succeeds before bundling

I also tried gem install jaro_winkler -v '1.5.2' --source 'https://testrepos.net/api/gems/rubygems/' but got the following error.

Fetching jaro_winkler-1.5.2.gem
Building native extensions. This could take a while...
ERROR:  Error installing jaro_winkler:
ERROR: Failed to build gem native extension.

Upvotes: 5

Views: 6854

Answers (1)

Shravan Ramamurthy
Shravan Ramamurthy

Reputation: 4096

Adding RUN apk update && apk add --virtual build-dependencies build-base to the docker file and then running bundle install resolved the issue.

# below line is just an example, and it might not work for you, use the correct repo name and image name
FROM testrepos.net/ruby:2.5-alpine3.7
RUN apk add --no-cache bash
RUN /bin/sh
RUN apk update && apk add --virtual build-dependencies build-base
RUN gem install bundler
RUN bundle install

Upvotes: 9

Related Questions