启动时出现rails log错误

时间:2010-08-01 02:55:15

标签: ruby-on-rails ubuntu

当我启动rails应用程序时,我看到以下错误:

$ script/server --environment=production
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
Rails Error: Unable to access log file. Please ensure that /home/me/test/railsapp/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/buffered_logger.rb:52:in `initialize': Permission denied - log/ (Errno::EACCES)
production_delayed_jobs.log
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/buffered_logger.rb:52:in `open'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/buffered_logger.rb:52:in `initialize'
    from /home/me/test/railsapp/config/initializers/dj.rb:3:in `new'
    from /home/me/test/railsapp/config/initializers/dj.rb:3
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:147:in `load_without_new_constant_marking'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:147:in `load'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:622:in `load_application_initializers'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:621:in `load_application_initializers'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:176:in `process'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /home/me/test/railsapp/config/environment.rb:10
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/server:3

我在chmod -R 0666目录上做了log,现在权限如下所示。 “我”是一个普通用户,我被抛弃了。

drw-rw-rw-  2 me me  4096 2010-07-31 18:48 log

仅当我执行sudo ls -al log时才会收到此商家信息:

drw-rw-rw-  2 me me 4096 2010-07-31 18:48 .
drwxr-xr-x 14 me me 4096 2010-07-31 19:32 ..
-rw-rw-rw-  1 me me   51 2010-07-31 18:45 ?development_delayed_jobs.log
-rw-rw-rw-  1 me me  527 2010-07-31 18:59 development.log
-rw-rw-rw-  1 me me   51 2010-07-31 18:48 ?production_delayed_jobs.log
-rw-rw-rw-  1 me me   51 2010-07-31 18:48 production.log

如果我执行ls -al log,我会收到以下错误(通过ssh):

Error:

ls: cannot access log/..: Permission denied
ls: cannot access log/
development_delayed_jobs.log: Permission denied
ls: cannot access log/development.log: Permission denied
ls: cannot access log/
production_delayed_jobs.log: Permission denied
ls: cannot access log/production.log: Permission denied
ls: cannot access log/.: Permission denied
total 0
d????????? ? ? ? ?                ? .
d????????? ? ? ? ?                ? ..
-????????? ? ? ? ?                ? ?development_delayed_jobs.log
-????????? ? ? ? ?                ? development.log
-????????? ? ? ? ?                ? ?production_delayed_jobs.log
-????????? ? ? ? ?                ? production.log

1 个答案:

答案 0 :(得分:1)

chmod the dir 755或775,你需要对目录执行访问才能访问它。