MailCatcher does not work with rbenv in a virtual machine

I installed MailCatcher in my virtual machine (VirtualBox) controlled by rbenv. But, mailcatcher does not work, it displays an 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 just like him, it works.

What will happen in my virtual machine?

--- details ---

OS: CentOS 6.5

Ruby: 2.1.1 with rbenv 0.4.0

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>' 
+6
source share
4 answers

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 downloads the i18n beta.

If you are not using rails 4.2 beta, you can uninstall beta

 gem uninstall i18n -v i18n-0.7.0.beta1 

This is stated in several problems with the gem.

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

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

+2
source

Using a combination of 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 folder, I started 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 folder, since everything in my project worked fine.

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

Later I ran into another problem with MailCatcher:

While I could get to http://127.0.0.1:1080 , sending email with an error

500 internal server errors completed

Net :: ReadTimeout (Net :: ReadTimeout)

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

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

I learned from this post discourse that Net::ReadTimeout caused by an error in MailCatcher, and a workaround is to run MailCatcher in the foreground using mailcatcher -f . This solved my problem, and now I can "catch" emails without any problems. Hooray!

+2
source

For those facing this problem with rbenv: I found a workaround. Make sure you are using a ruby ​​version that does not have the rails 4.2 beta set installed. (I had an older project that I worked with, and from there I had no problems installing and running mailcatcher.

It is possible that you need to create a new folder (for example, "mailcatcher"), create a .ruby version with a supported version so that you can run mailcatcher from there

+1
source

I also use rails 4.2 and solved the problem of installing another ruby ​​version for mailcatcher.

I use RVM and ruby ​​2.1.5 for rails, so I just installed and used 2.1.4 for mailcatcher:

 rvm install 2.1.4 --with-readline-dir=/usr/include/readline rvm 2.1.4 gem install mailcatcher mailcatcher 

Using rbenv you can do:

 CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline" rbenv install 2.1.4 rbenv shell 2.1.4 gem install mailcatcher mailcatcher 

This is not an ideal solution, but it is a good workaround until mailcatcher fixes it.

0
source

Source: https://habr.com/ru/post/974304/


All Articles