views:

234

answers:

4

I have an app provided by a vendor an I cant seem to start them on my local mac... I get the following error. Anyone know what I can do to get this thing working.

Apu:app Apu$ script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.2.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/Apu/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:57:in `initialize': No such file or directory - /Users/Apu/Documents/GDB_Parent/scr/GDB/app/log/development.log (Errno::ENOENT)
    from /Users/Apu/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:57:in `open'
    from /Users/Apu/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/servers/mongrel.rb:57
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from /Users/Apu/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /Users/Apu/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /Users/Apu/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /Users/Apu/.gem/ruby/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    from script/server:3
A: 

Check the appropriate environment files (environment.rb and presumably development.rb) for:

config.log_path = ...

It's hard to parse where the Rails root in the error path is, but I suspect that they're using the log_path config option to override the default log path (./log/*.log), and Rails is freaking out because it can't find the log file.

If you remove that option (or change the path to an existing log file), it should fix your problem.

Grant Heaslip
+3  A: 

It looks like the file /Users/Apu/Documents/GDB_Parent/scr/GDB/app/log/development.log cannot be created. Does the log directory exist and do you have permission to write to it?

Rob Di Marco
Looks like there was something wonky with the log dir permissions... I had tried changing the log dir to 777 and no luck... Deleted and recreated it an now things start right up.
Nick Faraday
A: 
  1. make sure log directory exists in your app root, otherwise create the log directory.
  2. touch development.log before running your app server
A: 

I found this error to be really annoying. In fact, I noticed that even when I created the file it would just be empty anyways. Any time I checked out a fresh project, I ran into this problem. To fix it I wrote an initializer that aliases the LogTrailer.initialize method and creates the file if it is not there. My code is below.

module Rails
  module Rack
    class LogTailer

      #
      # Override this method so that we can make sure the file it wants is there 
      # and we don't get errors on startup.
      #
      alias_method :original_initialize, :initialize
      def initialize(app, log = nil)

        if (log.nil?)
          path = Pathname.new(EnvironmentLog).cleanpath

          File.open(path, 'w') if !File.exists?(path)
        end

        original_initialize(app)
      end
    end
  end
end
Randy Simon