【问题标题】:Uncaught exception: undefined method `formatter' for nil:NilClass未捕获的异常:nil:NilClass 的未定义方法“格式化程序”
【发布时间】:2017-01-20 09:25:58
【问题描述】:

我在启动 rails 服务器时遇到以下错误:

未捕获的异常:nil:NilClass 的未定义方法“格式化程序”

还有另一个 StackOverflow 问题 NoMethodError on Rails Server 建议将 require './app' 添加到 config.ru 文件中,但是该解决方案对我不起作用(导致错误。)

我还尝试将 logger gem 添加到我的 gemfile 中,因为我最近卸载了所有 gem 来解决此问题。

Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile.

确切的控制台输出如下:

/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:142:in `log_to_stdout'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	/home/daniel/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/bin/rails:4:in `require'
	/home/daniel/Data/RubyOnRails/YoutubeBlog/bin/rails:4:in `<top (required)>'
Exiting
配置.ru

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

我删除了 Gemfile,运行了 bundle installbundle update,但没有解决问题。 (感谢您的建议)。

任何帮助将不胜感激。 :|

【问题讨论】:

  • 您可以发布您的config.ru 文件吗?

标签: ruby-on-rails ruby gemfile


【解决方案1】:

尝试删除 Gemfile.lock 文件,然后运行 ​​bundle install?

【讨论】:

  • 我已经这样做了一百万次,试图解决依赖问题。
【解决方案2】:

尝试运行bundle update,应该可以解决您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-12
    • 2014-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多