C语言 安装mailcatcher时出错:Error: Failed to build gem native extens



从今天起,我的docker构建因邮件捕获错误而中断,我在mac-m1上,我的Linux x86同事也从今天起有同样的问题

图像FROM arm64v8/php:7.4.12-fpmFROM php:7.4.12-fpm

原始版本

=> 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"

带有"cflag-solution'的构建不幸也失败了

=> 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"

更详细的日志

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);

是否存在不兼容性,但它是从哪里来的?

更新:看起来他们发布了sqlite3 gem: https://github.com/sparklemotion/sqlite3-ruby/releases/tag/v1.4.4的1.4.4版本,似乎修复了这个问题。我认为他们恢复了一些变化。


之前答:

我在ARM64上也遇到了这个问题。

看起来像一个新版本的sqlite3 gem碰巧昨天发布,所以我安装了以前的sqlite3v1.4.2版本,并为我修复了它。

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

这里使用单容器设计模式的解决方案

这意味着,我们将避免在主应用

的dockerbuild中安装邮件捕获应用。有一种简单的方法可以将您的邮件捕获应用程序提取到一个额外的容器中,但对现有的应用程序流程没有额外的或不利的

现有

Dockerfile

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

解决方案

Dockerfile主应用程序,但mailcatcher安装删除

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

use adocker- composer .yml对于单容器设计模式

version: "2.3"
services:
app:
build:
context: ../
dockerfile: deploy/app/Dockerfile
ports:
- "80:80"
- "2222:22"
env_file:
- env_development.env
mailcatcher:
image: schickling/mailcatcher
ports:
- 1080:1080
在<<p> strong> env_development.env 你需要添加这个VAR来修复一个可能的连接错误
SMTP_HOST=mailcatcher

最小的变化,为我们工作,很高兴它也可以帮助你