ruby 未捕获的异常:nil:NilClass的方法"formatter"未定义

7ajki6be  于 2022-12-29  发布在  Ruby
关注(0)|答案(3)|浏览(166)

启动rails服务器时,我遇到了以下错误:
未捕获的异常:nil:NilClass的方法"formatter"未定义
还有另一个StackOverflow问题NoMethodError on Rails Server,建议将require './app'添加到config.ru文件中,但该解决方案对我不起作用(导致错误)。
我还尝试在我的gemfile中添加logger gem,因为我最近卸载了所有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

Config.ru

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

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

我删除了宝石文件,运行bundle installbundle update没有解决问题。(谢谢你的建议)。
任何帮助都将不胜感激。|

aor9mmx1

aor9mmx11#

尝试删除Gemfile.lock文件,然后运行捆绑安装?

7lrncoxx

7lrncoxx2#

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

ryevplcw

ryevplcw3#

就我而言,
我注意到config/enviroment.rb中的源代码被删除了。

# Load the Rails application.
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize! <- this code is deleted

为了修复代码,正在运行rails。
我认为如果删除这段代码,日志记录器就没有准备好,Rails也不会启动。

相关问题