2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

メール動作確認でmailcatcherインストールする

Posted at

はじめに

Ruby on Rails5 速習実践ガイド」を参考にRailsの勉強しております。
メール送信の確認をするためにmailcatcherをインストールしようと試みたのですが、失敗しそのときの解決策を記事にしております。

環境

  • Mac
  • Ruby 2.7
  • Rails 6.1

mailcatcherのインストール失敗

mailcatcherをインストールするために、コマンドを叩くも失敗。
エラーログは下記になります。

$ sudo 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/***/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thin-1.5.1/ext/thin_parser
/Users/***/.rbenv/versions/2.7.2/bin/ruby -I /Users/***/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20210207-88991-1gmlkea.rb extconf.rb
checking for main() in -lc... yes
creating Makefile

current directory: /Users/***/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thin-1.5.1/ext/thin_parser
make "DESTDIR=" clean

current directory: /Users/***/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.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");
         ~~~~~~ ^  ~~~~~~~~~
/Library/Developer/CommandLineTools/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/***/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/thin-1.5.1 for inspection.
Results logged to /Users/***/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-20/2.7.0/thin-1.5.1/gem_make.out

mailcatcherのインストールが失敗しているので、mailcatcherの起動もうまくいきません。

$ mailcatcher
-bash: mailcatcher: command not found

解決策

下記コマンドでインストールできます(確認済み)。

$ gem install thin -v '1.5.1' -- --with-cflags="-Wno-error=implicit-function-declaration"
$ gem install mailcatcher

インストールが失敗していた原因はthinが未インストールだったため、thinをインストールするようにしています。

mailcatcherのインストールが成功すれば、正常に起動します。

$ mailcatcher
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080/
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

参考
Installation Fails on Catalina #430

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?