ruby-on-rails - gem install mailcatcher 失败 - 错误 : Error installing mailcatcher: ERROR: Failed to build gem native extension

标签 ruby-on-rails ruby rubygems mailcatcher

我在 macOS Catalina 10.15.7 ,使用 rbenv(版本 rbenv 1.1.2-36-g60c9339)和 ruby​​ 版本 2.6.3 ( ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]ruby -v 的输出)用于我的项目。
我需要安装 mailcatcher 来检查我的应用程序生成的电子邮件。
正在运行 gem install mailcatcher在我的项目文件夹中,命令失败并出现以下错误:

➜ gem install mailcatcher
Building native extensions. This could take a while...
ERROR:  Error installing mailcatcher:
    ERROR: Failed to build gem native extension.

    current directory: /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thin-1.5.1/ext/thin_parser
/Users/karansapolia/.rbenv/versions/2.6.3/bin/ruby -I /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/2.6.0 -r ./siteconf20201103-23665-1tzqkaj.rb extconf.rb
checking for main() in -lc... yes
creating Makefile

current directory: /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thin-1.5.1/ext/thin_parser
make "DESTDIR=" clean

current directory: /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thin-1.5.1/ext/thin_parser
make "DESTDIR="
compiling parser.c
parser.rl:112:17: warning: comparison of integers of different signs: 'long' and 'unsigned long' [-Wsign-compare]
  assert(pe - p == len - off && "pointers aren't same distance");
         ~~~~~~ ^  ~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:93:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e) : (void)0)
                        ^
parser.rl:142:7: error: implicit declaration of function 'thin_http_parser_has_error' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  if (thin_http_parser_has_error(parser) ) {
      ^
parser.rl:142:7: note: did you mean 'http_parser_has_error'?
./parser.h:44:5: note: 'http_parser_has_error' declared here
int http_parser_has_error(http_parser *parser);
    ^
parser.rl:144:14: error: implicit declaration of function 'thin_http_parser_is_finished' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  } else if (thin_http_parser_is_finished(parser) ) {
             ^
1 warning and 2 errors generated.
make: *** [parser.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/thin-1.5.1 for inspection.
Results logged to /Users/karansapolia/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/thin-1.5.1/gem_make.out
安装其他 gems 工作正常。 gem install mailman完美地工作。只有 mailcatcher 失败.
如何在没有错误的情况下安装 mailcatcher?

最佳答案

我运行了以下命令,它对我有用

gem install mailcatcher -- --with-cflags="-Wno-error=implicit-function-declaration"

关于ruby-on-rails - gem install mailcatcher 失败 - 错误 : Error installing mailcatcher: ERROR: Failed to build gem native extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64662290/

相关文章:

ruby-on-rails - 使用延迟作业在后台处理方法

ruby - 仅将特定子字符串推送到 Ruby 中的数组

ruby - 尝试安装 termios gem 会导致 make 错误

ruby - Bundle 不能与 rbenv 一起使用并且不能 gem install bundler

ruby-on-rails - Capistrano RVM 和 Ubuntu RVM 不是一个函数,选择 'rvm use ...' 的 rubies 是行不通的

mysql - database.yml 中的 utf8 编码问题在插入时丢弃字符串

ruby-on-rails - 试图删除数据库中的重复条目但得到 nil id

ruby-on-rails - 对来自 assert_select 测试的 rspec 反馈感到困惑

ruby - 如何打印或调试 Chef 属性

ruby-on-rails - 如何为现有的 Rails 应用构建版本 API?