Build Error using Alpine Linux and Bundler


I am trying to build an image for my ruby application but every time my build gets to running bundle install it fails due to an io/console error.

Error seen here:

Any ideas?


Looks like this is a Ruby issue. Can you add gem 'io-console' to the Gemfile and try again.


1 Like

Unfortunately even when I do that I am still getting the exact same error.

Any other ideas?


I tried to install io-console gem in alpine:edge container from packages found from your docker build log and it complains about not having ruby header files (ruby.h) packages which usually comes with ruby-dev package.

gem install io-console
Fetching: io-console-0.4.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing io-console:
	ERROR: Failed to build gem native extension.

    /usr/bin/ruby -r ./siteconf20150914-17-1piw7f1.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /usr/lib/ruby/gems/2.2.0/gems/io-console-0.4.2 for inspection.
Results logged to /usr/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/io-console-0.4.2/gem_make.out

And looks like the ruby-dev package corresponding to the ruby version you are installing doesn’t exist in the Alpine repo.

So this is indicates that for your bundler install to work you need ruby development packages. This is a Alpine linux specific issue and not a docker issue.


1 Like

Okay thank you for your help

Hi @joeegrigg,
Did you find the solution to your issue ? I’m facing exactly the same one :frowning:

Any interesting additional information in /usr/lib/ruby/gems/2.2.0/extensions/x86_64-linux/2.2.0/io-console-0.4.2/gem_make.out?

If you apk add --update ruby-dev does it work?

EDIT: Just saw that’s not working. You might have to follow procedures such as

Personally, my experience using alpine for Ruby-based apps has not been good, even for simple ones. You definitely should consider whether the disk space vs. ease of use tradeoff of using alpine vs. something like debian is worth it for your use case, especially since I’ve found native gem builds of alpine have tendency to balloon to several hundreds of megabytes in size anyway.