3

I'm trying to start the Rails Server, but I get the following error and the server shuts down. I suspect I'm missing a dependency, but I'm a Ruby noob, so I very well could be wrong.

 => Booting WEBrick
 => Rails 4.1.0 application starting in development on `http://0.0.0.0:3000`
 => Run `rails server -h` for more startup options
 => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
 => Ctrl-C to shutdown server 
    Exiting 
    /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:133:in
 `log_to_stdout': undefined method `formatter' for nil:NilClass
 (NoMethodError)    from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/server.rb:67:in
 `start'    from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:81:in
 `block in server'  from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
 `tap'  from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:76:in
 `server'   from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in
 `run_command!'     from
 /Users/darrin/inventory/vendor/ruby/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in
 `<top (required)>'     from bin/rails:4:in `require'   from bin/rails:4:in
 `<main>'

UPDATED: I do not have "execjs" or "therubyracer" gems in my Gemfile. Here is what I have:

source 'https://rubygems.org'
ruby '2.1.1'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.1.0'

group :development do
  gem 'sqlite3', '1.3.8'
end

gem 'sass', '3.3.6'
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'haml'
gem 'railties'
gem 'faraday', '~> 0.9.0'
gem 'annyang_rails'
gem 'savon', '~> 2.3.0'
gem 'httparty'
gem 'speechcloud', '~> 0.1.1'
gem 'json', '~> 1.8.1'
gem 'sinatra', '~> 1.4.5'
gem 'rack', '~> 1.4'
gem 'rack-protection', '~> 1.4'
gem 'permutation', '~> 0.1.8'
gem 'tilt', '~> 1.3'
gem 'bacon', '~> 1.2.0'
gem 'activesupport', '~> 4.1.0'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

As far as starting Rails server, I simply type Rails Server. Nothing else.

BTW, if you can't tell, I'm very new to RoR.

  • 1
    I think the issue is with `Logger`, Are you using some custom logs? or How are you starting rails server with any options? Can you share more details? – Pramod Shinde May 10 '14 at 06:28
  • Do you have "execjs" and "therubyracer" gems in your Gemfile? – Ruby Racer May 10 '14 at 07:11
  • Added details to my original post. – Darrin Dickey May 10 '14 at 12:24
  • Server errors could easily have to do with the javascript runtime environment. Check if you have nodejs installed on your system and if you dont try adding execjs and therubyracer to your gemfile... Just try, nothing to lose... – Ruby Racer May 10 '14 at 16:20
  • I've generated a new rails project, took your Gemfile and could start the server with Ruby 2.0 and 2.1 on OS X. So the problem might not be related to a specific gem in this list. – 2called-chaos May 10 '14 at 16:34
  • OK @2called-chaos, Rick Peck & Ruby Racer, so your comments helped me narrow down the issue some. I have a config.ru file which says: require './app' run Sinatra::Application Server start fails as listed above. If I change config.ru to Rails default: require ::File.expand_path('../config/environment', __FILE__) run Rails.application the server starts fine. – Darrin Dickey May 11 '14 at 00:33

2 Answers2

2

log_to_stdout': undefined method 'formatter' for nil:NilClass (NoMethodError)

That's your error, and as pointed out in the comments, it looks like a problem with the logger

I can only surmise the issue will be with either a dependency (can you post your Gemfile please), or with your environment (not having ruby installed properly or something)

Can you post your Gemfile for us?

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
1

So, I finally came up with a solution. Thank you for putting me on the right track. I eventually tracked down the problem to my config.ru file. I changed it to:

require ::File.expand_path('../config/environment',  __FILE__)
require './app'
run Sinatra::Application

This finally got the Rails Server up and running.