Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string) on Heroku

I have a Rails application where I use regex-based rules to categorize transactions. In my seeds.rb, I create some categories and rules, then import transactions from a CSV file (also utf8-encoded) and allow them to be categorized. This process works fine on my development machine, but when I run it on Heroku, I get:

incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)

I am running the Cedar Stack, Rails 2.3.15. I have put

# encoding: utf-8

at the top of all my source files and I've set the encoding to utf-8 in my app config, so I'm not sure what else could be causing this problem. I'm wondering if has something to do with the Heroku configuration.

like image 644
cayblood Avatar asked Jan 11 '13 17:01

cayblood


1 Answers

The issue could be caused by invisible characters that are ignored by your local operating system, ensuring proper encoding takes place whereas on Heroku, the characters mess up the magic number declaration at the top of the file and you end up with both ASCII-8BIT and UTF-8.

Since the file that is having issues contains the regex, it's probably your model class instead of seeds.rb.

There are many ways to view invisible characters in your file. In vi, just set the option :set list

like image 97
Musannif Zahir Avatar answered Oct 24 '22 17:10

Musannif Zahir