Home > OS >  Error installing mailcatcher: ERROR: Failed to build gem native extension
Error installing mailcatcher: ERROR: Failed to build gem native extension

Time:06-18

since today, my docker build broke with a mailcatcher error, im on mac-m1, my colleague with linux x86 has the same problem also since today

the image FROM arm64v8/php:7.4.12-fpm or FROM php:7.4.12-fpm

the original build

=> CACHED [12/58] RUN apt-get install -qy ruby ruby-dev rubygems build-essential libsqlite3-dev
=> ERROR [13/58] RUN gem install mailcatcher --no-ri --no-rdoc"

the build with "cflag-solution' unfortunately failed, too

=> CACHED [12/58] RUN apt-get install -qy ruby ruby-dev rubygems build-essential libsqlite3-dev
=> [13/58] RUN gem install thin
=> ERROR [14/58] RUN gem install mailcatcher -- --with-cflags="-Wno-error=implicit-function-declaration"

more detailed log

RUN gem install mailcatcher -- --with-cflags="-Wno-error=implicit-function-declaration":
#19 1.925 Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
#19 1.925 This could take a while...
#19 14.76 Successfully installed eventmachine-1.0.9.1
#19 14.76 Successfully installed mini_mime-1.1.2
#19 14.76 Successfully installed mail-2.7.1
#19 14.76 Successfully installed rack-1.6.13
#19 14.76 Successfully installed rack-protection-1.5.5
#19 14.76 Successfully installed tilt-2.0.10
#19 14.76 Successfully installed sinatra-1.4.8
#19 14.76 Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
#19 14.76 This could take a while...
#19 16.25 ERROR:  Error installing mailcatcher:
#19 16.25   ERROR: Failed to build gem native extension.
#19 16.25
#19 16.25     current directory: /var/lib/gems/2.5.0/gems/sqlite3-1.4.3/ext/sqlite3
#19 16.25 /usr/bin/ruby2.5 -r ./siteconf20220614-8-b43h7c.rb extconf.rb --with-cflags=-Wno-error=implicit-function-declaration
#19 16.25 checking for sqlite3.h... yes
#19 16.25 checking for pthread_create() in -lpthread... yes
#19 16.25 checking for -ldl... yes
#19 16.25 checking for sqlite3_libversion_number() in -lsqlite3... yes
#19 16.25 checking for rb_proc_arity()... yes
#19 16.25 checking for rb_integer_pack()... yes
#19 16.25 checking for sqlite3_initialize()... yes
#19 16.25 checking for sqlite3_backup_init()... yes
#19 16.25 checking for sqlite3_column_database_name()... yes
#19 16.25 checking for sqlite3_enable_load_extension()... yes
#19 16.25 checking for sqlite3_load_extension()... yes
#19 16.25 checking for sqlite3_open_v2()... yes
#19 16.25 checking for sqlite3_prepare_v2()... yes
#19 16.25 checking for sqlite3_int64 in sqlite3.h... yes
#19 16.25 checking for sqlite3_uint64 in sqlite3.h... yes
#19 16.25 creating Makefile
#19 16.25
#19 16.25 current directory: /var/lib/gems/2.5.0/gems/sqlite3-1.4.3/ext/sqlite3
#19 16.25 make "DESTDIR=" clean
#19 16.25
#19 16.25 current directory: /var/lib/gems/2.5.0/gems/sqlite3-1.4.3/ext/sqlite3
#19 16.25 make "DESTDIR="
#19 16.25 compiling aggregator.c
#19 16.25 compiling backup.c
#19 16.25 compiling database.c
#19 16.25 database.c: In function 'rb_sqlite3_disable_quirk_mode':
#19 16.25 database.c:84:1: error: expected ';' before '}' token
#19 16.25  }
#19 16.25  ^
#19 16.25 database.c: In function 'exec_batch':
#19 16.25 database.c:748:57: warning: passing argument 3 of 'sqlite3_exec' from incompatible pointer type [-Wincompatible-pointer-types]
#19 16.25      status = sqlite3_exec(ctx->db, StringValuePtr(sql), hash_callback_function, callback_ary, &errMsg);

is there an incompatibility, but where did it come from?

CodePudding user response:

UPDATE: Looks like they released v1.4.4 of the sqlite3 gem: https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v1.4.4 which seems to fix it. I think they reverted some changes.


Previous answer:

I ran into this too on my ARM64 build.

Looks like a new version of sqlite3 gem was coincidentally released yesterday so I installed the previous sqlite3 v1.4.2 version and that fixed it for me.

FROM php:7.4.12-fpm
RUN apt-get update && apt-get install -qy ruby ruby-dev rubygems build-essential libsqlite3-dev
RUN gem install sqlite3 --version '1.4.2'
RUN gem install mailcatcher

CodePudding user response:

here a solution using single-container design pattern

this means, we are avoiding the install of a mailcatcher app in our dockerbuild for the main app

there is an easy way to extract your mailcatcher app into an extra container but with no extras or disadvantages for the existing app flow

EXISTING

Dockerfile of main app with mailcatcher inside

FROM php:7.4.12-fpm
...
# mailcatcher install
RUN apt-get update -qy && apt-get install -qy ruby ruby-dev rubygems build-essential libsqlite3-dev &&\
    gem install mailcatcher --no-ri --no-rdoc
...
EXPOSE 80 8081 22 1080

SOLUTION

Dockerfile of main app but mailcatcher install removed

FROM php:7.4.12-fpm
...
# remove mailcatcher install here and its mail port 1080 in expose
...
EXPOSE 80 8081 22

use a docker-compose.yml for single-container design pattern

version: "2.3"
services:
    app:
        build:
            context: ../
            dockerfile: deploy/app/Dockerfile
        ports:
            - "80:80"
            - "2222:22"

    mailcatcher:
        image: schickling/mailcatcher
        ports:
            - 1080:1080

minimal changes, works for us, glad it can help you too

  • Related