i am new to augeas, and i am getting plenty of errors like:

Could not evaluate: invalid byte sequence in UTF-8

in special i expect augeas to honor the encoding declaration in a XML-file

<?xml version="1.0" encoding="ISO-8859-1"?>

but in the source code of the lens i can not see that this is taken into account, but i could be wrong sense i do not understand much of the lenses format: https://github.com/hercules-team/augeas/blob/master/lenses/xml.aug

or that Java-Properties-File are always treated as ISO-8859-1, and again no traces of any encoding in the source code of the lens: https://github.com/hercules-team/augeas/blob/master/lenses/properties.aug

my first question is: does augeas infer the right encoding for XML and properties-Files?

my second question is: is there any way to tell augeas which encoding to use?

to repoduce

assuming systems default encoding is UTF-8:

vi testUTF.properties

# Käse
# tèté

And everything is fine:

puppet-test:~ # augtool --noautoload
augtool> set /augeas/load/Properties/lens Properties.lns
augtool> set /augeas/load/Properties/incl "/root/testUTF.properties"
augtool> load
augtool> print /augeas/files/root/testUTF.properties
/augeas/files/root/testUTF.properties/path = "/files/root/testUTF.properties"
/augeas/files/root/testUTF.properties/mtime = "1491478421"
/augeas/files/root/testUTF.properties/lens = "Properties.lns"
/augeas/files/root/testUTF.properties/lens/info = "/usr/share/augeas/lenses/dist/properties.aug:25.20-.53:"
augtool> print /files/root/testUTF.properties
/files/root/testUTF.properties/#comment[1] = "K\303\244se"
/files/root/testUTF.properties/abc = "test"
/files/root/testUTF.properties/#comment[2] = "t\303\250t\303\251"
/files/root/testUTF.properties/persona = "ni\303\261o"

Now converting the file into iso-8859-1:

iconv --from-code UTF-8 --to-code ISO-8859-1 -o testIso.properties testUTF.properties


puppet-test:~ # augtool --noautoload
augtool> set /augeas/load/Properties/lens Properties.lns
augtool> set /augeas/load/Properties/incl "/root/testIso.properties"
augtool> load
augtool> print /augeas/files/root/testIso.properties
/augeas/files/root/testIso.properties/path = "/files/root/testIso.properties"
/augeas/files/root/testIso.properties/mtime = "1491478512"
/augeas/files/root/testIso.properties/lens = "Properties.lns"
/augeas/files/root/testIso.properties/lens/info = "/usr/share/augeas/lenses/dist/properties.aug:25.20-.53:"
augtool> print /files/root/testIso.properties
/files/root/testIso.properties/#comment[1] = "K\344se"
/files/root/testIso.properties/abc = "test"
/files/root/testIso.properties/#comment[2] = "t\350t\351"
/files/root/testIso.properties/persona = "ni\361o"

and now every thing is still ok, arghhh, should not be...

So, it is then for sure NOT an augeas problem, but a puppet problem

Refomulating my question:

is there any way to tell the Puppet augeas resource which encoding to use?

Many thanks in advance

  • 1
    I'm unsure if the file encoding is relevant to most Augeas lenses. Can you expand on precisely what you're running to generate that error message? It doesn't look like an Augeas error - it looks like Ruby, or even Puppet. – Dominic Cleal Apr 5 '17 at 11:48
  • thanks @DominicCleal, indeed not an augeas issue, but puppets – mmoossen Apr 6 '17 at 11:59
  • 1
    There is no encoding option for Puppet's augeas resource type. You should probably file this as a bug against the project if it's occurring on a supported version (but with more information, e.g. versions, --debug and --trace output etc). – Dominic Cleal Apr 6 '17 at 12:07
  • 1
    When you need to rephrase a question, don't forget to rephrase the subject to reflect it. I did that for you, using your words. – Xalorous Apr 28 '17 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.