1

I am using a Dockerfile to build a custom ruby image as follows:

FROM debian:9

RUN apt-get update \
    && apt-get install -y \
        build-essential \
        gcc \
        openssl \
        procps \
        wget \
        zlib1g-dev \
    && cd /tmp \
    && wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz \
    && tar -xvzf ruby-2.0.0-p0.tar.gz \
    && ls -al \
    && cd ruby-2.0.0-p0 \
    && ./configure \
    && make \
    && make install

USER someuser
WORKDIR /home/someuser

The build finishes OK.

As a matter of fact, from within the image:

$ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]

But when I spin up the image and try to install bundler

$ gem install bundler
ERROR:  Loading command: install (LoadError)
    cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

Why is that, given I have installed openssl?

edit: It is NOT a duplicate of this because (although I am using OSX) I am compiling ruby WITHIN a debian:9 image and openssl gets installed within the image (Dockerfile)

edit: installing libssl-dev as also indicated in the potential duplicate question does not solve the issue either:

(custom-ruby)*➣ $ docker run -it --user=root pkaramol/test-ruby-new bash
root@bde5e149ced7:/home/someuser# dpkg -l | grep -i ssl
ii  libssl-dev:amd64          1.1.0j-1~deb9u1            amd64        Secure Sockets Layer toolkit - development files
ii  libssl-doc                1.1.0j-1~deb9u1            all          Secure Sockets Layer toolkit - development documentation
ii  libssl1.1:amd64           1.1.0j-1~deb9u1            amd64        Secure Sockets Layer toolkit - shared libraries
ii  openssl                   1.1.0j-1~deb9u1            amd64        Secure Sockets Layer toolkit - cryptographic utility
root@bde5e149ced7:/home/someuser# gem install bundler
ERROR:  Loading command: install (LoadError)
    cannot load such file -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass
pkaramol
  • 16,451
  • 43
  • 149
  • 324
  • Possible duplicate of [ruby 2.0 rails gem install error "cannot load such file -- openssl"](https://stackoverflow.com/questions/15129355/ruby-2-0-rails-gem-install-error-cannot-load-such-file-openssl) – anothermh Jul 01 '19 at 17:41
  • 1
    pls check my edit about the duplication – pkaramol Jul 01 '19 at 17:43
  • It looks like you're saying it's not a duplicate because the system where Ruby lives isn't macOS. I suggest that you actually read through the answers on that question and try them, because it **will** solve your issue. – anothermh Jul 01 '19 at 17:49
  • 1
    You’re only installing the runtime libraries, not the header files you need to compile applications. `libssl-dev` gets mentioned in one or two of the answers to the linked question. – David Maze Jul 01 '19 at 17:51
  • 1
    pls check my second edit about `libssl-dev` – pkaramol Jul 01 '19 at 18:02
  • why dont you use ruby debian image in [`ruby docker repo`](https://docs.docker.com/samples/library/ruby/)? Or at least base on that – Martin Jul 01 '19 at 19:13
  • I want some pretty old versions, not available in the above repo – pkaramol Jul 01 '19 at 20:11
  • I dug thru this a bit and I agree, it's not a duplicate and none of the solutions work. It appears to be an issue w/ openssl libs not being recognized. I couldn't get a working solution, but I thought I'd throw this out there: this might be a good time to try rvm and see if it will install the old version. If you cd into your tmp/ruby directory, there's an ext/openssl folder in there. `ruby extconf.rb` will generate the errors that I think you're looking for (I just couldn't figure out how to work around them) – Jay Dorsey Jul 02 '19 at 02:33

0 Answers0