I’m trying to upload a template containing a sql dump: file.sql.erb
Since this is a sql dump, I cannot add the usual workaround to the top of the file
encoding: utf-8
My locale is set correctly:
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=“en_US.UTF-8”
However, when I try to upload the cookbook, I get:
$ knife cookbook upload <cookbook_name>
Uploading <cookbook_name> [0.0.1]
FATAL: Erb template templates/default/file.sql.erb has a syntax error:
FATAL: -:75: invalid multibyte char (US-ASCII)
FATAL: -:1: invalid multibyte char (US-ASCII)
FATAL: -:1: syntax error, unexpected $end
FATAL: …hese brave men foughtd diedr freedom.\",\“audio\”:{…
FATAL: … ^
Please help.
Thank you.
Bruce Davis
bdavis2-consultant@scholastic.com
On Wednesday, August 7, 2013 at 5:04 PM, Davis, Bruce wrote:
However, when I try to upload the cookbook, I get:
$ knife cookbook upload <cookbook_name>
Uploading <cookbook_name> [0.0.1]
FATAL: Erb template templates/default/file.sql.erb has a syntax error:
FATAL: -:75: invalid multibyte char (US-ASCII)
FATAL: -:1: invalid multibyte char (US-ASCII)
FATAL: -:1: syntax error, unexpected $end
FATAL: ...hese brave men foughtd diedr freedom.\",\"audio\":{...
FATAL: ... ^
The syntax check works by piping the output of erubis -X
(extract ruby code) to ruby -c
(ruby syntax check). It's not clear from the error which one of this is failing.
Some things you might be able to try:
Add this to your template:
<% #encoding: utf-8
%>
Hack the syntax check by creating a script called erubis
that higher precedence in the PATH than the real one.
I think the real solution to this is to add :env => {"LC_ALL" => nil}
to the call to shell_out on this line:
You could probably monkey patch that in via your knife.rb (though if this solves your issue, please submit a proper patch, too).
HTH,
--
Daniel DeLeo
I found a solution: upgrade Ruby to 2.0.0-p247 as it makes UTF-8 the default encoding.
I can now upload the cookbook with UTF-8 characters directly to our chef server:
$ knife cookbook upload test_cookbook
Uploading test cookbook [0.0.1]
Uploaded 1 cookbook.
Bruce Davis
bdavis2-consultant@scholastic.com