sj26 / mailcatcher

Catches mail and serves it through a dream.
http://mailcatcher.me
MIT License
6.3k stars 575 forks source link

Not compatible with newest version of Rails 7.0.4.3 #537

Closed TCCDevelopment closed 1 year ago

TCCDevelopment commented 1 year ago

When I put mailcatcher in the Gemfile like so:

gem 'mailcatcher'

and I run bundler, an older version is installed (from Gemfile.lock: mailcatcher (0.2.4))

When doing that, mailcatcher crashes with this error:

mailcatcher                                                    
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
/Users/<username>/.rvm/gems/ruby-3.2.1/gems/eventmachine-1.2.7/lib/eventmachine.rb:1490:in `event_callback': undefined method `close' for 17:Integer (NoMethodError)

              io.close
                ^^^^^^
Did you mean?  clone
        from /Users/<username>/.rvm/gems/ruby-3.2.1/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.2.4/lib/mail_catcher.rb:21:in `run'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.2.4/bin/mailcatcher:44:in `<top (required)>'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/bin/mailcatcher:25:in `load'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/bin/mailcatcher:25:in `<main>'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `eval'
        from /Users/<username>/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `<main>'

When I try to declare the newest version like so:

gem 'mailcatcher', '>= 0.8.2', '< 1.0'

and I run bundler, I get this error:

bundler                                                        
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Could not find compatible versions

Because rails >= 7.0.4.3 depends on actionpack = 7.0.4.3
  and actionpack >= 7.0.0.alpha1 depends on rack >= 2.2.0, < 3.A,
  rails >= 7.0.4.3 requires rack >= 2.2.0, < 3.A.
And because mailcatcher >= 0.6.4 depends on rack ~> 1.5,
  rails >= 7.0.4.3 is incompatible with mailcatcher >= 0.6.4.
So, because Gemfile depends on rails >= 7.0.4.3, < 7.1.A
  and Gemfile depends on mailcatcher >= 0.8.2, < 1.0,
  version solving has failed.

Can you please assist?

sj26 commented 1 year ago

Please don’t put mailcatcher into your Gemfile:

https://github.com/sj26/mailcatcher#bundler

Instead, run:

gem install mailcatcher
TCCDevelopment commented 1 year ago

gem install mailcatcher

When I try running that command, I get the following error in the console.

Building native extensions. This could take a while...
Successfully installed eventmachine-1.0.9.1
Building native extensions. This could take a while...
ERROR:  Error installing mailcatcher:
        ERROR: Failed to build gem native extension.

    current directory: /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/ext/thin_parser
/Users/topher/.rvm/rubies/ruby-3.2.1/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile

current directory: /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/ext/thin_parser
make DESTDIR\= sitearchdir\=./.gem.20230421-9260-9jhbt1 sitelibdir\=./.gem.20230421-9260-9jhbt1 clean

current directory: /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/ext/thin_parser
make DESTDIR\= sitearchdir\=./.gem.20230421-9260-9jhbt1 sitelibdir\=./.gem.20230421-9260-9jhbt1
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:99:25: note: expanded from macro 'assert'
    (__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __ASSERT_FILE_NAME, __LINE__, #e) : (void)0)
                        ^
parser.rl:142:7: error: call to undeclared function 'thin_http_parser_has_error'; ISO C99 and later do not support implicit function declarations [-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: call to undeclared function 'thin_http_parser_is_finished'; ISO C99 and later do not support implicit function declarations [-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/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1 for inspection.
Results logged to /Users/topher/.rvm/gems/ruby-3.2.1/extensions/x86_64-darwin-21/3.2.0/thin-1.5.1/gem_make.out
sj26 commented 1 year ago

Please see the instructions for thin in the readme:

https://github.com/sj26/mailcatcher#ruby

TCCDevelopment commented 1 year ago

Please see the instructions for thin in the readme:

https://github.com/sj26/mailcatcher#ruby

Thank you, @sj26. That did run the installer for thin and I was able to install the mailcatcher gem. But, when I try to run mailcatcher I get an error with thin:

Rails % ruby -v
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-darwin21]

√ Rails % rails -v
Rails 7.0.4.3

√ Rails % gem install thin -v 1.5.1 -- --with-cflags="-Wno-error=implicit-function-declaration"
Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
Successfully installed thin-1.5.1
Parsing documentation for thin-1.5.1
Installing ri documentation for thin-1.5.1
Done installing documentation for thin after 0 seconds
1 gem installed

√ Rails % gem install mailcatcher    
Successfully installed skinny-0.2.4
Successfully installed rack-protection-1.5.5
Successfully installed sinatra-1.4.8
Successfully installed mailcatcher-0.8.2
Parsing documentation for skinny-0.2.4
Installing ri documentation for skinny-0.2.4
Parsing documentation for rack-protection-1.5.5
Installing ri documentation for rack-protection-1.5.5
Parsing documentation for sinatra-1.4.8
Installing ri documentation for sinatra-1.4.8
Parsing documentation for mailcatcher-0.8.2
Installing ri documentation for mailcatcher-0.8.2
Done installing documentation for skinny, rack-protection, sinatra, mailcatcher after 169 seconds
4 gems installed

√ Rails % mailcatcher 
Starting MailCatcher v0.8.2
==> smtp://127.0.0.1:1025
/Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/lib/thin/server.rb:104:in `block in initialize': uninitialized constant Thin::Server::Fixnum (NameError)

        when Fixnum, /^\d+$/ then port    = arg.to_i
             ^^^^^^
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/lib/thin/server.rb:102:in `each'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/lib/thin/server.rb:102:in `initialize'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/lib/thin/server.rb:145:in `new'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/thin-1.5.1/lib/thin/server.rb:145:in `start'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:190:in `block (2 levels) in run!'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:233:in `rescue_port'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:189:in `block in run!'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run_machine'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.8.2/lib/mail_catcher.rb:180:in `run!'
        from /Users/topher/.rvm/gems/ruby-3.2.1/gems/mailcatcher-0.8.2/bin/mailcatcher:6:in `<top (required)>'
        from /Users/topher/.rvm/gems/ruby-3.2.1/bin/mailcatcher:25:in `load'
        from /Users/topher/.rvm/gems/ruby-3.2.1/bin/mailcatcher:25:in `<main>'
        from /Users/topher/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `eval'
        from /Users/topher/.rvm/gems/ruby-3.2.1/bin/ruby_executable_hooks:22:in `<main>'