Marcel Falliere
Marcel Falliere

Reputation: 1894

App crashed because of syntax error in an helper utf-8 encoded

I'm using heroku to deploy my app (rails 3). Ok so I do the usual, which is a git commit, a git push heroku master => deployment is ok, gems are installed, etc...

When running my app in the web browser, I get an heroku error : app crashed.

In the ouput of heroku logs, this got my attention :
==> dyno-2625316.log (crash) <==
/disk1/home/slugs/321697_5debeb5_58eb-de03f9a2-bd41-487c-aae7-6b20b9281d85/mnt/.bundle/gems/ruby/1.8/gems/activesupport-
3.0.0/lib/active_support/dependencies.rb:239:in `require': /disk1/home/slugs/321697_5debeb5_58eb-de03f9a2-bd41-487c-aae7
-6b20b9281d85/mnt/app/helpers/string_helper.rb:6: syntax error, unexpected kEND, expecting $end (SyntaxError)

It seems that there's a syntaxt error in my string_helper module. This file is encoded in utf-8 (I precise it because it can be important).

This file contains the following lines (empty) :

module StringHelper




end

Note : I had a groups_helper file with methods in it, and the app crashed because of that. I deleted it and now the error points to this stringhelper.

What I will do now : delete this file an redeploy.

Edit I did delete string_helper. Now the error is on events_controller.rb, the very same error

==> dyno-2625316.log (crash) <==
/disk1/home/slugs/321697_401813b_58eb-4b2e3910-f043-4e4f-8eae-8631c932a62b/mnt/.bundle/gems/ruby/1.8/gems/activesupport-
3.0.0/lib/active_support/dependencies.rb:239:in `require': /disk1/home/slugs/321697_401813b_58eb-4b2e3910-f043-4e4f-8eae
-8631c932a62b/mnt/app/controllers/events_controller.rb:104: syntax error, unexpected kEND, expecting $end (SyntaxError)

line 104 is the last end of the class

class EventsController < ApplicationController

  layout 'event'

  def index
  end

  ...

end

This file is also in utf-8

Upvotes: 1

Views: 279

Answers (1)

kch
kch

Reputation: 79512

It looks like your files have the BOM characters at their beginning.

The BOM is not required for UTF-8, and will actually cause issues with ruby 1.8.

You need to remove those and set your editor not to write them.

http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8

Upvotes: 1

Related Questions