我在使用 rbenv 管理的 VM (VirtualBox) 中安装了 MailCatcher。 但是,mailcatcher 不起作用,在下面显示错误消息:
`require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)
i18n好像没装,我装了
[vagrant@localhost ~]$ gem list i18n
*** LOCAL GEMS ***
i18n (0.7.0.beta1)
我同样安装在 AWS EC2 中,它可以工作。
我的 VM 中发生了什么?
--- 详情 ---
操作系统:CentOS 6.5
Ruby:2.1.1 和 rbenv 0.4.0
完整的错误信息:
[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>'
最佳答案
结合使用已发布的答案,这是我想出的解决方案:
我的环境:
- rbenv
- 导轨 4.1.8
- 国际化 (0.7.0.beta1)
我的问题:
在我现有的 Rails 项目文件夹中运行 gem install mailcatcher
后,我运行了 mailcatcher
并得到:
`require': cannot load such file -- i18n/core_ext/string/interpolate (LoadError)
我不想在现有项目文件夹中更新 i18n gem,因为我项目中的所有内容都运行良好。
根据@joostvanrijn 的建议,我决定专门为 MailCatcher 创建一个单独的 Rails 项目文件夹。我将文件夹命名为 mailcatcher
。
在我新创建的 /mailcatcher
文件夹中,我运行了 gem install mailcatcher
。然后我运行了 gem update i18n
,这让我进入了 i18n-0.7.0
。
最后,我调用了 mailcatcher
,它运行得很顺利。
后来,我遇到了 MailCatcher 的另一个问题:
虽然我可以访问 http://127.0.0.1:1080
,但发送电子邮件会失败
Completed 500 Internal Server Error
Net::ReadTimeout (Net::ReadTimeout)
我试图通过转到 http://127.0.0.1:1080
并单击“退出”来退出 MailCatcher,但这只会将我带到 http://mailcatcher.me而不是真正终止进程。
为了终止进程,我使用了 lsof -i -n -P | grep TCP
查找在 127.0.0.1:1025
和 127.0.0.1:1080
上运行的进程并使用 kill -9 PID
.
我从中学到了Discourse post Net::ReadTimeout
是由于 MailCatcher 中的错误造成的,解决方法是使用 mailcatcher -f
在前台运行 MailCatcher。这解决了我的问题,现在我可以毫无问题地“接收”电子邮件。耶!
关于ruby - MailCatcher 不适用于 VM 上的 rbenv,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25486365/