CircleCI-Public / cimg-ruby

The CircleCI Ruby Docker Convenience Image.
https://circleci.com/developer/images/image/cimg/ruby
MIT License
33 stars 39 forks source link

Bug Report: Unable to Install gems with native extensions (e.g. `bcrypt`, `pg`, etc) on cimg/ruby:3.3.0 #155

Closed ksylvest closed 10 months ago

ksylvest commented 10 months ago

Describe the bug Unable to install gems with native extensions (e.g. bcrypt, pg, etc) on 3.3.0 images due to missing jemalloc headers. Attempting to the following error:

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

    current directory: /home/circleci/.rubygems/gems/bcrypt-3.1.20/ext/mri
/usr/local/bin/ruby extconf.rb
creating Makefile

current directory: /home/circleci/.rubygems/gems/bcrypt-3.1.20/ext/mri
make DESTDIR\= sitearchdir\=./.gem.20240102-13-gnagja sitelibdir\=./.gem.20240102-13-gnagja clean

current directory: /home/circleci/.rubygems/gems/bcrypt-3.1.20/ext/mri
make DESTDIR\= sitearchdir\=./.gem.20240102-13-gnagja sitelibdir\=./.gem.20240102-13-gnagja
compiling bcrypt_ext.c
In file included from /usr/local/include/ruby-3.3.0/ruby/internal/config.h:22,
                 from /usr/local/include/ruby-3.3.0/ruby/ruby.h:15,
                 from /usr/local/include/ruby-3.3.0/ruby.h:38,
                 from bcrypt_ext.c:1:
/usr/local/include/ruby-3.3.0/x86_64-linux/ruby/config.h:82:40: fatal error: jemalloc/jemalloc.h: No such file or directory
   82 | #define RUBY_ALTERNATIVE_MALLOC_HEADER <jemalloc/jemalloc.h>
      |                                        ^
compilation terminated.
make: *** [Makefile:248: bcrypt_ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/circleci/.rubygems/gems/bcrypt-3.1.20 for inspection.
Results logged to /home/circleci/.rubygems/extensions/x86_64-linux/3.3.0/bcrypt-3.1.20/gem_make.out

To Reproduce

docker run -it cimg/ruby:3.3.0 bash
gem install bcrypt

Expected behavior Gems install.

Workarounds This appears to be an issue with the Dockerfile.template including a flag not present in any other Dockerfile for usage of jemalloc. It appears this flag was introduced without building an image:

https://github.com/CircleCI-Public/cimg-ruby/pull/139

ksylvest commented 10 months ago

Fixed with https://github.com/CircleCI-Public/cimg-ruby/pull/156

swiknaba commented 10 months ago

156 fixed the exact same issue for me 👍 , thanks @ksylvest for contributing to this :)