sj26 / mailcatcher

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

macOS 13 issues #521

Closed LJ-03 closed 11 months ago

LJ-03 commented 1 year ago

Long-time user and fan of mail catcher. Suddenly unable to load mailcatcher in the browser.

Running Ruby (3.0.0) on Rails (7.0.2.2) and am able to start mailcatcher (v 0.8.2):

mailcatcher
Starting MailCatcher v0.8.2
/Users/liam/.rvm/gems/ruby-3.0.0/gems/digest-3.1.0/lib/digest.rb:20: warning: already initialized constant Digest::REQUIRE_MUTEX
/Users/liam/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0/digest.rb:6: warning: previous definition of REQUIRE_MUTEX was here
==> 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.

The warnings don't seem to be causing the issue, and when I go to the web interface, I'm just met with "can't connect to server" error. I've tried on Safari, Chrome and Firefox, all are the same. Curiously, when I go back to the terminal to re-run mailcatcher, it starts as if it hadn't been initialised. If I start mailcatcher, then run a lsof on port 1025, it returns a process, but not after I've tried to access mailcatcher in the browser.

It seems that trying to open mailcatcher in the browser is killing the server, but I can't figure out why. Most recent major changes I've made out of the ordinary are:

I'm using RVM, and I also tried running uninstalling and running the RVM-installation guide, which gave the same logs as above, minus the errors. I've also tried uninstalling and reinstalling mailcatcher multiple times, restarting my Mac, running through multiple repositories, through VSCode and iterm. Not sure what else to try.

Also, even though I was getting no errors, I tried installing mailcatcher via the command:

gem install mailcatcher -- --with-cflags="-Wno-error=implicit-function-declaration" from https://stackoverflow.com/questions/64662290/gem-install-mailcatcher-fails-with-error-error-installing-mailcatcher-error but that also didn't work.

Any help is greatly appreciated!

LJ-03 commented 1 year ago

development.rb for each repo:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = { :address => '127.0.0.1', :port => 1025 }
  config.action_mailer.raise_delivery_errors = false
LJ-03 commented 1 year ago

Update: It seems that running mailcatcher --foreground works! I found this workaround from here: https://github.com/sj26/mailcatcher/issues/426 - my issue seems to be different, however... Any idea as to why the normal mailcatcher command won't work?

iamfaycal commented 1 year ago

I can confirm, with version 0.8.2 on MacOS, It only works with the --foreground flag

jlamberg commented 1 year ago

@LJ-03, you mentioned Rails 7. Are you running Mailcatcher from inside or from your Rails app's codebase? If yes, this might be the reason for it, and there is a note about it in the README: https://github.com/sj26/mailcatcher#bundler

@iamfaycal, what versions of Ruby and macOS you are running?

I am running Mailcatcher 0.8.2 on macOS 12.5.1. I tested it both with Ruby 2.7.6 and 3.0.4, did separate installs from scratch, and all is working as expected. I am running Mailcatcher from a separate project on its own, and not from Rails, though.

So, maybe this is a macOS 13-only bug? Or maybe there are other factors together causing this bug to surface 🤷

brianlukoff commented 1 year ago

I'm having the same issue on macOS 13.0.1.

LJ-03 commented 1 year ago

@jlamberg Sorry for the late response on this.

I've tried running it both inside and out of the app, same issue for both. Currently running 2.6.10 globally, and 2.7.2 in app, but have also tested in another v3.0.4 app.

I've just updated my macOS to Ventura 13.0.1. Still the same issue after updating.

Seems you might be correct about MacOS 13! Hopefully we can see a fix soon, but at least we have a workaround for now

sj26 commented 1 year ago

Sorry I'm not running macOS 13 so I haven't observed this issue. If anyone figures it out please let me know! The workaround for now is probably using --foreground mode.

sj26 commented 1 year ago

I have pushed another pre-release, v0.9.0.beta2, which updates thin. Does it help? Please try it:

gem install mailcatcher --pre
davidahopp commented 1 year ago

Still silently failing for me. Specs: Ruby 2.7.5 macOS 13.1

➜  code mailcatcher -v           
Starting MailCatcher v0.9.0.beta2
==> 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.
➜  code ps aux | grep mailcatcher
         54452   0.0  0.0 408626880   1328 s004  S+    8:52PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mailcatcher
         54444   0.0  0.0 408847952   1968   ??  S     8:52PM   0:00.00 ruby /Users/.../.rvm/gems/ruby-2.7.5/bin/mailcatcher -v   
➜  code curl localhost:1080
curl: (52) Empty reply from server
➜  code ps aux | grep mailcatcher
         54471   0.0  0.0 408626880   1328 s004  S+    8:52PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mailcatcher
➜  code 

Debug notes if not noticed, the process shows running until attempting to navigate to localhost:1080

bebertOA commented 1 year ago

I've installed the 0.90-beta2 too and am getting this same issue with mailcatcher running but getting 127.0.0.1 refused to connect. Here is the startup for me


Password:
Starting MailCatcher v0.9.0.beta2
==> smtp://127.0.0.1:1025
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Library/Ruby/Gems/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Library/Ruby/Gems/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:214: warning: previous definition of BUFSIZE was here
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Library/Ruby/Gems/2.6.0/gems/net-protocol-0.2.1/lib/net/protocol.rb:541: warning: previous definition of Socket was here
==> http://127.0.0.1:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.
bebert@Bens-MBP ~ %```
nitredd commented 1 year ago

As @stepheneb mentions in #525 , the problem seems to be when using Ruby 2.x.

I'm running on MacOS 13.2 with Ruby 3.1.0 (rbenv - ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin21]), and I wasn't able to use the build at RubyGems.org because of the old version of Thin but, when I clone and build the main branch, I am able to get it to run normally.

➜  mailcatcher git:(main) ✗ bundle exec rake assets
➜  mailcatcher git:(main) ✗ bundle exec rake package
WARNING:  open-ended dependency on net-smtp (>= 0) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on capybara (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on capybara-screenshot (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on coffee-script (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on rspec (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on rake (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on rdoc (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on sass (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on selenium-webdriver (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on sprockets (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on sprockets-sass (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on sprockets-helpers (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  open-ended dependency on uglifier (>= 0, development) is not recommended
  use a bounded requirement, such as '~> x.y'
WARNING:  See https://guides.rubygems.org/specification-reference/ for help
  Successfully built RubyGem
  Name: mailcatcher
  Version: 0.9.0.beta2
  File: mailcatcher-0.9.0.beta2.gem
➜  mailcatcher git:(main) ✗ gem uninstall -i /Users/nitin.katkam/Documents/landd/rubyProjects/mailcatcher/.gem mailcatcher
Remove executables:
    mailcatcher, catchmail

in addition to the gem? [Yn]
Removing mailcatcher
Removing catchmail
Successfully uninstalled mailcatcher-0.9.0.beta2
➜  mailcatcher git:(main) ✗ gem install mailcatcher-0.9.0.beta2.gem --install-dir `pwd`/.gem
Successfully installed sqlite3-1.6.0-arm64-darwin
Successfully installed mailcatcher-0.9.0.beta2
Parsing documentation for sqlite3-1.6.0-arm64-darwin
Parsing documentation for mailcatcher-0.9.0.beta2
Installing ri documentation for mailcatcher-0.9.0.beta2
Done installing documentation for sqlite3, mailcatcher after 0 seconds
2 gems installed
➜  mailcatcher git:(main) ✗ .gem/gems/mailcatcher-0.9.0.beta2/bin/mailcatcher
Starting MailCatcher v0.9.0.beta2
==> 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.
➜  mailcatcher git:(main) ✗ ps aux | grep mailcatcher
nitin.katkam     87604   0.2  0.0 407962688     48 s001  S+    1:11PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mailcatcher
nitin.katkam     87374   0.0  0.0 409420304   1920   ??  S     1:10PM   0:00.01 ruby .gem/gems/mailcatcher-0.9.0.beta2/bin/mailcatcher
➜  mailcatcher git:(main) ✗ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome http://127.0.0.1:1080
Opening in existing browser session.
objc[88596]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2225c9518) and /Applications/Google Chrome.app/Contents/Frameworks/Google Chrome Framework.framework/Versions/109.0.5414.119/Libraries/libGLESv2.dylib (0x109763b30). One of the two will be used. Which one is undefined.
➜  mailcatcher git:(main) ✗ ps aux | grep mailcatcher
nitin.katkam     87374   0.0  0.2 409560592  25680   ??  S     1:10PM   0:00.25 ruby .gem/gems/mailcatcher-0.9.0.beta2/bin/mailcatcher
nitin.katkam     88635   0.0  0.0 407962688     48 s001  S+    1:15PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mailcatcher

To help with further testing, I can try running with System-Ruby or an older version of Ruby installed with rbenv.

sj26 commented 11 months ago

Sorry, I'm not sure what's going on here. And I don't have macOS 13 yet so can't diagnose further. But it sounds like something to do with the daemonisation. I know macOS changed some stuff around how processes go into the background. Perhaps older ruby doesn't handle this well any more.

v0.9.0 has been released. It supports ruby 3.1 and 3.2. Please try upgrading both ruby and then mailcatcher to see if it helps:

gem install mailcatcher

Otherwise the best workaround I can offer is running mailcatcher in the foregound:

mailcatcher --foreground

(Use nohup etc if you need.)

Please reopen this issue if you still have issues and have further information, or if you find a fix.