Missing header file

ruby
docker
rubygems

#1

Hello,
I’m, trying to build app with version 2.0. I have problem with debugging. In my docker file I have:

RUN apk add --update ruby-dev build-base
RUN gem install bcrypt -v '3.1.10'

If I run command manually on container with image bundle passes but then passed to CircleCI I get:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/bcrypt-3.1.10/ext/mri
/usr/bin/ruby2.3 -r ./siteconf20170209-274-1mtghh4.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 /var/lib/gems/2.3.0/gems/bcrypt-3.1.10 for
inspection.
Results logged to
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/bcrypt-3.1.10/gem_make.out

What could be reason for that full Docker file here:

FROM alpine:3.4

RUN apk --no-cache add \
    tini \
    nodejs \
    ffmpeg \
    ruby \
    curl \
    git \
  && npm install -g \
    nightwatch@'<1.0' \

RUN npm install phantomjs-prebuilt
RUN apk add --update bash wget ca-certificates openssl git tar
RUN apk update && apk upgrade && apk --update add \
    ruby ruby-irb ruby-rake ruby-io-console ruby-bigdecimal ruby-json ruby-bundler \
    libstdc++ tzdata bash ca-certificates \
    &&  echo 'gem: --no-document' > /etc/gemrc
RUN gem install bundler --no-ri --no-rdoc
RUN apk add --update ruby-dev
RUN apk add --update openssh
RUN apk add --update ruby-dev build-base
RUN gem install bcrypt -v '3.1.10'

#2

I recommend using the Ruby alpine image and building off it. They update the necessary env vars for you. Here is Ruby 2.1:

https://raw.githubusercontent.com/docker-library/ruby/e32433a12099d96dc5a1b28a011b73af4f17cfff/2.1/alpine/Dockerfile

Their other Dockerfiles are linked from their Docker Hub:
https://hub.docker.com/_/ruby


#3

@rohara I made a switch to ruby image you provided now my dockerfile is:

FROM ruby:2.3-alpine

RUN apk --no-cache add \
    # Install NodeJS:
    nodejs \
    curl \
    git \
  && npm install -g \
    nightwatch@'<1.0' 

RUN npm install phantomjs-prebuilt
RUN apk add --update alpine-sdk
RUN apk add --update bash wget ca-certificates openssl git tar
RUN apk add --update openssh
RUN gem install bcrypt -v '3.1.10'


COPY wait-for.sh /usr/bin/wait-for
COPY entrypoint.sh /usr/bin/entrypoint

ENTRYPOINT ["/bin/sh"]

But seems that there is same issue. I tried to exec gem installation manually localy and it seems to work:

/ # gem install bcrypt -v '3.1.10'
Building native extensions.  This could take a while...
Successfully installed bcrypt-3.1.10
1 gem installed

#4

It still seems like the $PATH is wrong. You can always modify the base image Dockerfile itself since they provide that. It may resolve your problem to install it at the same time as other modules. I have definitely gotten this working. I posted some of my workflow here:


#5