0

I am faced with the error below when starting the rails server:

Uncaught exception: undefined method `formatter' for nil:NilClass

There is another StackOverflow question, NoMethodError on Rails Server which suggests to add require './app' to the config.ru file, however that solution did not work for me (it resulted in an error.)

I also tried adding in the logger gem to my gemfile, as I recently uninstalled all gems to resolve this issue.

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.

The exact console output is as follows:

/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

I deleted the Gemfile, ran bundle install and bundle update which did not solve the problem. (Thanks for the suggestions).

Any help would be appreciated. :|

Community
  • 1
  • 1
danielbker
  • 392
  • 1
  • 3
  • 21

3 Answers3

0

Try deleting the Gemfile.lock file and then run bundle install?

Aniket Rao
  • 758
  • 7
  • 16
0

Try running bundle update, that should solve your problem.

Arun Kumar Mohan
  • 11,517
  • 3
  • 23
  • 44
Severin
  • 8,508
  • 14
  • 68
  • 117
0

In my case,

I noticed that the source code is deleted at config/enviroment.rb.

# Load the Rails application.
require_relative "application"

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

To fix the code, rails is running.

I think if this code is deleted, the logger isn't prepared and rails not started.