Skip to content

Instantly share code, notes, and snippets.

@znz
Last active December 14, 2015 16:48
Show Gist options
  • Save znz/5117644 to your computer and use it in GitHub Desktop.
Save znz/5117644 to your computer and use it in GitHub Desktop.
gsub_file with UTF-8 regexp causes Encoding::CompatibilityError. related issue is https://github.com/wycats/thor/issues/191
# -*- coding: utf-8 -*-
create_file "config/locales/foo.yml", <<-'YAML'
ja:
foo: "foo"
YAML
gsub_file "config/locales/foo.yml", /"foo"/, '"bar"'
create_file "config/locales/hoge.yml", <<-'YAML'
ja:
hoge: "ほげ"
YAML
gsub_file "config/locales/hoge.yml", /"ほげ"/, '"ふが"'
% bundle exec rails -v
Rails 3.2.12
% bundle exec rake rails:template LOCATION=https://gist.github.com/znz/5117644/raw/f0280d2f3ad7faaa40a578600675d9b8d481e242/ex.rb
create config/locales/foo.yml
gsub config/locales/foo.yml
create config/locales/hoge.yml
gsub config/locales/hoge.yml
rake aborted!
incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment