Rails 我安装配置了 gitlab,但访问时返回 500 错误

angryfrog · 2013年11月14日 · 最后由 zj0713001 回复于 2013年11月14日 · 15192 次阅读

我安装并配置了 gitlab,其他地方都没什么问题。nginx 也配置成功了。但访问时返回 500 错误,

访问日志如下:

Connecting to database specified by database.yml Creating scope :opened. Overwriting existing method Issue.opened. Creating scope :of_projects. Overwriting existing method MergeRequest.of_projects. Creating scope :closed. Overwriting existing method MergeRequest.closed. Creating scope :public. Overwriting existing method Snippet.public. Creating scope :private. Overwriting existing method Snippet.private. Creating scope :fresh. Overwriting existing method ProjectSnippet.fresh. Creating scope :non_expired. Overwriting existing method ProjectSnippet.non_expired. Creating scope :expired. Overwriting existing method ProjectSnippet.expired. Started GET "/users/sign_in" for 127.0.0.1 at 2013-11-14 08:16:59 +0800 Processing by Devise::SessionsController#new as HTML Rendered devise/sessions/_new_base.html.haml (3.7ms) Rendered devise/sessions/_oauth_providers.html.haml (0.1ms) Rendered devise/sessions/new.html.haml within layouts/devise (4.9ms) Rendered layouts/_head.html.haml (64.3ms) Completed 500 Internal Server Error in 74ms

ActionView::Template::Error (couldn't find file 'underscore' (in /home/git/gitlab/app/assets/javascripts/application.js:31)): 5: GitLab 6: = favicon_link_tag 'favicon.ico' 7: = stylesheet_link_tag "application" 8: = javascript_include_tag "application" 9: = csrf_meta_tags 10: = include_gon 11: app/views/layouts/head.html.haml:8:in `_app_views_layoutshead_html_haml1073825523124287833_36704500' app/views/layouts/devise.html.haml:3:in `_app_views_layouts_devise_html_haml_2225179123726725323_33668600'

Started GET "/static.css" for 127.0.0.1 at 2013-11-14 08:16:59 +0800

ActionController::RoutingError (No route matches [GET] "/static.css"): vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:incall' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in call_app' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:inblock in call' vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in tagged' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:incall' vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:incall' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/runtime.rb:17:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/lock.rb:15:incall' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in forward' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:infetch' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in lookup' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:incall!' vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/engine.rb:479:incall' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/application.rb:223:in call' vendor/bundle/ruby/2.0.0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:inmethod_missing' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/builder.rb:134:in call' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/urlmap.rb:64:inblock in call' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in each' vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/urlmap.rb:49:incall' vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:552:in process_client' vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:632:inworker_loop' vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in spawn_missing_workers' vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:142:instart' vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/bin/unicorn_rails:209:in <top (required)>' vendor/bundle/ruby/2.0.0/bin/unicorn_rails:23:inload' vendor/bundle/ruby/2.0.0/bin/unicorn_rails:23:in `

'

关于日志中 ActionView::Template::Error (couldn't find file 'underscore'的问题,我尝试 gem install underscore 了,但安装后这个问题依然存在。请问这些问题如何解决?rails 新手,感谢大家帮帮忙了。

你 gem install underscore 了不代表你的 rails 项目用上了呀,你还得在 Gemfile 中把 underscore 加进来吧

gem list "underscore-rails" 是什么版本

#1 楼 @qichunren 在 Gemfile 中有

underscore-rails

gem "underscore-rails", "~> 1.4.4"

这么一句,并且 bundle 也执行完毕了。

#2 楼 @zj0713001 是 underscore-rails-1.4.4

我的环境是:[email protected]

刚才我尝试把 /home/git/gitlab/app/assets/javascripts/application.js中的 //= require underscore 这行删除掉,就可以运行了。有些奇怪呀,这个 underscore 明明装了,可是引用不进来。也不知道注释掉它会有什么影响不。请问哪位知道原因?

我明明安装了 underscore-rails-1.4.4。但 require underscore 却找不到这个包

bundle show underscore-rails看是什么呀

#6 楼 @qichunren [git@localhost gems]$ bundle show underscore-rails /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/underscore-rails-1.4.

是这个

问题解决了!看来是 underscore-rails 的版本问题

我修改 Gemfile,将 gem "underscore-rails", "~> 1.4.4" 改为 gem "underscore-rails", "~> 1.5.2"

重新执行了下 bundle install --no-deployment,再把/home/git/gitlab/app/assets/javascripts/application.js 中的//= require underscore 恢复,重启 gitlab 就好了,看来是版本问题。

THX 各位!!

#7 楼 @angryfrog 为啥会在项目文件夹里呢 你用 rvm 了么~ 你的 gitlab 部署的什么版本~ 我的部署时还发生过需要原生 ruby 版本 1.9.2+ 的情况 基于 6.1 的

需要 登录 后方可回复, 如果你还没有账号请 注册新账号