Setting locale fails in Perl-based Snap

I’ve created a snap of a Perl app on Ubuntu 18.04 that I’m trying to run on 14.04. I’ve set the the following environment for it in snapcraft.yaml:

   environment:
      LANGUAGE: "C.UTF-8"
      LANG: "C.UTF-8"
      LC_ALL: "C.UTF-8"

However, when I run the resulting snap on 14.04, I get a locale warning, although the diagnostic reports all my variables have been set:

# /snap/bin/ec2-consistent-snapshot ---help
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "C.UTF-8",
        LC_ALL = "C.UTF-8",
        LANG = "C.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

If I run locale -a on the 14.04 system, I can see that “C.UTF-8” locale is installed, so that’s not the issue. I believe the issue is that some locale data is missing inside the snap, but I’m not sure how to fix that.

I found a previous discussion about locale support in snaps, but it wasn’t clear to me from reading that how I might resolve my own issue.

How can I get the ec2-consistent-snapshot snap to run without this locale warning?

Thanks.

1 Like

you could try something similar to:

https://github.com/maxiberta/htop-snap/blob/master/snap/htop.wrapper

and generate the locales on first start of your snap…

1 Like

I repeated your locale-fix workaround on the ec2-consistent-snapshot snap, and it resolved that issue, but now I’m back to getting a segfault / core dump when running it on Ubuntu 14.04 (a separate issue, I presume).

Thanks for the tip, @ogra!

1 Like

Is it possible to generate the locale data directly in-snap?

I actually never tried, it might be possible to do the generation at build time.

2 Likes