部署Rails应用程序:LoadError:无法加载此类文件 - I18n

时间:2018-04-01 12:12:21

标签: ruby-on-rails

我想做什么

我正在尝试部署我的rails应用并运行bundle exec rake assets:precompile RAILS_ENV=production

错误消息

DEPRECATION WARNING: ActionView::Template::Handlers::Erubis is deprecated and will be removed from Rails 5.2. Switch to ActionView::Template::Handlers::ERB::Erubi instead. (called from require at /usr/local/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81)
rake aborted!
LoadError: cannot load such file -- I18n
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/app/config/initializers/class_extensions.rb:2:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/engine.rb:655:in `block in load_config_initializer'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/notifications.rb:168:in `instrument'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/engine.rb:654:in `load_config_initializer'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/engine.rb:611:in `each'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/engine.rb:611:in `block in <class:Engine>'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `each'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:48:in `tsort_each_child'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
/usr/local/bundle/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!'
/usr/local/bundle/gems/railties-5.1.6/lib/rails/application.rb:445:in `block in run_tasks_blocks'
/usr/local/bundle/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
/usr/local/bundle/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/bundle:104:in `load'
/usr/local/bundle/bin/bundle:104:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace)

在我的开发者计算机上运行此命令可以正常工作。在我的服务器上运行它会出现此错误。我不知道机器上有什么不同。

我尝试了什么

  • 包括i18n中的Gemfile gem 'i18n', '~> 1.0' - 没有帮助。
  • 在调用rake任务之前用gem install i18n安装gem - 没有帮助。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

低调'我'为我工作:

- require 'I18n'
+ require 'i18n'

虽然我不明白为什么它不起作用;在require 'I18n'中运行irb工作正常。