Ask Your Question
0

How to resolve: incompatible character encoding errors which prevent catalog compilation

asked 2014-08-26 10:35:26 -0500

hesco gravatar image

Short answer is this: LANG=en_US.utf8 puppet agent -t.

The longer answer follows:

I started by encountering this error:

On the node running puppet agent, my catalog run bombs out like so --

Error: Failed to apply catalog: incompatible character encodings: UTF-8 and ASCII-8BIT

What follows is my dialogue with myself on the #puppet channel at some hour when others were occupied. The irc channel made a convenient support bear, but I thought I'd document my process here in hopes that it might help others in the future, or perhaps elicit further ideas.

How and where would I set the LANG on an apache-passenger enabled puppet master to avoid: "Error: Failed to apply catalog: incompatible character encodings: UTF-8 and ASCII-8BIT"

I see that /etc/init.d/apache2 runs its targets with this alias: APACHE2CTL="$ENV /usr/sbin/apache2ctl";

so apparently I can embed this setting in the environment for the apache server.
But in case I may later run other applications on this same apache server, I'm wondering if it might make sense to limit the scope of this setting to the passenger or even the puppet master instead.

wonder if I can set an environmental variable in the relevant vhost container.
and indeed apache's SetEnv seems meant for this purpose and if this example is correct will scope itself to a vhost. May have answered that question, testing now.

Well, my test failed, with this in the passenger vhost for the puppet master:
SetEnv LANG en_US.UTF-8

will try again setting it in the /etc/init.d/apache2 script next.

Now testing this line in /etc/init.d/apache2: ENV="env -i LANG=en_US.UTF-8 PATH=/usr/local/bin:/usr/bin:/bin"

That failed as well. This is the output of file -i for every file which has changed since the last successful run of the catalog for this node.
They all report: charset=us-ascii, wonder how it is utf8 got introduced here.

This: find . -name *.pp -type f -print | xargs file -i shows that the entire catalogue is built from charset=us-ascii,
except a handful of files in the environment which are charset=binary, all from the epel module off the forge, but that should not be relevant here as the OS is Ubuntu 14.04.

This: # find . -type f -print | xargs file -i | grep -v us-ascii | grep -v '.git' | grep -v epel returns a handful of results: several README.md, CHANGELOG.md, an .rb out of stdlib, and five files from <module>/files/ paths

I would certainly appreciate some one else's thoughts on this: Error: Failed to apply catalog: incompatible character encodings: UTF-8 and ASCII-8BIT

kerframil on #puppet pointed me at this:
https://tickets.puppetlabs.com/browse/PUP-2793

So apparently the issue was on the client. Attempts to update-locale did not seem to change the output of locale. But this ran the catalog past the previous error and to completion:

LANG=en_US.utf8 puppet agent -t.

looks like I need to create an ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-10-11 15:40:19 -0500

hesco gravatar image

updated 2014-10-11 15:41:54 -0500

I continue to regularly use:

LANG=en_US.utf8 puppet agent -t

particularly when running puppet on docker containers.

But since posting this, I have also had occasion to advise a couple of folks to create a symlink in their /usr/lib/locale directory to account for various spellings of the locale. Apparently case matters to some applications.

-- Hugh

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-08-26 10:31:46 -0500

Seen: 2,823 times

Last updated: Oct 11 '14