Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailCatcher does not work with rbenv on VM

I installed MailCatcher in my VM (VirtualBox) managed with rbenv. But, mailcatcher does not work, puts out error message below:

`require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)

It seems that i18n did not install, but I installed it.

[vagrant@localhost ~]$ gem list i18n

*** LOCAL GEMS ***

i18n (0.7.0.beta1)

I installed in AWS EC2 as same as that, it works.

What's happen in my VM?

--- details ---

OS: CentOS 6.5

Ruby: 2.1.1 with rbenv 0.4.0

entire error messages:

[vagrant@localhost ~]$ mailcatcher--http-ip 192.168.33.12
/home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/core_ext/string/interpolation.rb:2:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/core_ext/string.rb:9:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/core_ext.rb:2:in `block in <top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/core_ext.rb:1:in `each'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-3.2.19/lib/active_support/core_ext.rb:1:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailcatcher-0.5.12/lib/mail_catcher.rb:1:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /home/vagrant/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/mailcatcher-0.5.12/bin/mailcatcher:3:in `<top (required)>'
    from /home/vagrant/.rbenv/versions/2.1.1/bin/mailcatcher:23:in `load'
    from /home/vagrant/.rbenv/versions/2.1.1/bin/mailcatcher:23:in `<main>'
like image 896
lassy Avatar asked Aug 25 '14 12:08

lassy


3 Answers

Using a combination of the posted answers, here is the solution I came up with:

My environment:

  • rbenv
  • rails 4.1.8
  • i18n (0.7.0.beta1)

My problem: After running gem install mailcatcher in my existing rails project's folder, I ran mailcatcher and got:

`require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)

I did not want to mess with updating the i18n gem in my existing project's folder as everything in my project was working fine.

Taking @joostvanrijn's advice, I decide to create a separate rails project folder specifically for MailCatcher. I named the folder mailcatcher. In my newly created /mailcatcher folder, I ran gem install mailcatcher. Then I ran gem update i18n, which got me to i18n-0.7.0. Finally, I called mailcatcher and it ran without a hitch.

Later, I ran into another issue with MailCatcher:

While I could get to http://127.0.0.1:1080, sending emails would fail with

Completed 500 Internal Server Error

Net::ReadTimeout (Net::ReadTimeout)

I tried to quit MailCatcher by going to http://127.0.0.1:1080 and clicking "Quit", but that would just take me to http://mailcatcher.me and not actually kill the process.

To kill the process, I used lsof -i -n -P | grep TCP to find the processes running on 127.0.0.1:1025 and 127.0.0.1:1080 and used kill -9 PID.

I learned from this Discourse post that Net::ReadTimeout is due to a bug in MailCatcher and the workaround is to run MailCatcher in the foreground using mailcatcher -f. That solved my problem and now I can "catch" emails without issue. Yay!

like image 109
Tod Birdsall Avatar answered Nov 02 '22 00:11

Tod Birdsall


rails 4.2 beta / activesupport-4.2.0.beta2 depends on i18n (< 0.8, >= 0.7.0.beta1).

mailcatcher (0.5.12) throws your error if it loads the beta gem of i18n.

If you're not using rails 4.2 beta then you could uninstall the beta version

gem uninstall i18n -v i18n-0.7.0.beta1

This is referenced in multiple issues with the gem

https://github.com/sj26/mailcatcher/issues/164

https://github.com/sj26/mailcatcher/issues/155

like image 45
s01ipsist Avatar answered Nov 01 '22 23:11

s01ipsist


For anyone encountering this issue with rbenv: I've found a workaround. Make sure you use a ruby version that does not have the rails 4.2 beta gem installed. (I had an older project which i cd'd into and from there i had no problem installing and running mailcatcher.

It's not unlikely that you have to create a new folder (named "mailcatcher" for example) create a .ruby-version with the supported version so you can run mailcatcher from there

like image 1
joost Avatar answered Nov 02 '22 00:11

joost