Unicorn won't start after 7.1.0 update (with quick fix)
Created by: Libbux
This error occurs after using the update script to update to gitlab 7.1.0 (from 7.0.0, oviously). I re-applied my stashed changes (although none of them touched the file throwing the error in question.
After using the init.d script to attempt to start both the unicorn and sidekiq, the following error is thrown in log/unicorn.stderr.log
:
[2014-07-25T10:14:54.859195 #11685] INFO -- : Refreshing Gem list
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require': /home/git/gitlab/app/helpers/commits_helper.rb:186: invalid multibyte char (US-ASCII) (SyntaxError)
/home/git/gitlab/app/helpers/commits_helper.rb:186: invalid multibyte char (US-ASCII)
/home/git/gitlab/app/helpers/commits_helper.rb:186: syntax error, unexpected $end, expecting keyword_end
... return link_to "Browse File »", project_blob_path(project,...
... ^
Which is followed by a massive stack trace and cascading errors.
It seems as though app/helpers/commits_helper.rb
doesn't like the comma or right double chevron used (it doesn't look like a normal comma!), since the file has no explicit encoding declaration (so it defaults to US-ASCII in ruby < 2.0.0) and that character isn't an ASCII character.
A quick fix for this issue is to add the following lines at the very top for app/helpers/commit_helper.rb
:
#!/bin/env ruby
# encoding: utf-8
Which forces the file to be interpreted as UTF-8, and the syntax error is no longer thrown. Starting gitlab after that (via the init script) worked fine and I haven't had a problem since.
There is also a stack overflow answer that explains this quick fix.