lxc-create fails if LANG is not valid

Bug #1166841 reported by James Hunt
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
High
Unassigned

Bug Description

If LANG is not 'en_GB.UTF-8', lxc-create fails:

$ echo $LANG
fr_CA.UTF8
$ sudo lxc-create -n foo -t ubuntu -- raring

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-i386 ...
Copy /var/cache/lxc/raring/rootfs-i386 to /var/lib/lxc/foo/rootfs ...
Copying rootfs to /var/lib/lxc/foo/rootfs ...
lxc-create: failed to execute template 'ubuntu'
lxc-create: aborted
$ export LANG=C
$ sudo lxc-create -n foo -t ubuntu -- raring

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-i386 ...
Copy /var/cache/lxc/raring/rootfs-i386 to /var/lib/lxc/foo/rootfs ...
Copying rootfs to /var/lib/lxc/foo/rootfs ...
lxc-create: failed to execute template 'ubuntu'
lxc-create: aborted
$ export LANG=en_GB.UTF-8

lxc-create: No config file specified, using the default config /etc/lxc/default.conf
Checking cache download in /var/cache/lxc/raring/rootfs-i386 ...
Copy /var/cache/lxc/raring/rootfs-i386 to /var/lib/lxc/raring/rootfs ...
Copying rootfs to /var/lib/lxc/raring/rootfs ...
Generating locales...
  en_GB.UTF-8... done
Generation complete.

##
# The default user is 'ubuntu' with password 'ubuntu'!
# Use the 'sudo' command to run tasks as root in the container.
##

'ubuntu' template installed
'raring' created

Revision history for this message
James Hunt (jamesodhunt) wrote :

Adding '-x' to the ubuntu template the problem is with locale-gen:

+ configure_ubuntu /var/lib/lxc/raring/rootfs raring raring
+ rootfs=/var/lib/lxc/raring/rootfs
+ hostname=raring
+ release=raring
+ cat
+ cat
+ cat
+ '[' '!' -f /var/lib/lxc/raring/rootfs/etc/init/container-detect.conf ']'
+ '[' -z '' ']'
+ chroot /var/lib/lxc/raring/rootfs useradd --create-home -s /bin/bash ubuntu
+ echo ubuntu:ubuntu
+ chroot /var/lib/lxc/raring/rootfs chpasswd
+ '[' -z fr_CA.UTF8 ']'
+ chroot /var/lib/lxc/raring/rootfs locale-gen fr_CA.UTF8
lxc-create: failed to execute template 'ubuntu'
lxc-create: aborted

Revision history for this message
Simon Déziel (sdeziel) wrote :

It seems there is a typo in your fr_CA.UTF8 locale. Maybe try with "fr_CA.UTF-8" ?

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

serge@sergelap:~$ sudo chroot /var/lib/lxc/r2/rootfs local-gen fr_CA.UTF8
chroot: failed to run command 'local-gen': No such file or directory
serge@sergelap:~$ which locale-gen
/usr/sbin/locale-gen
serge@sergelap:~$ sudo chroot /var/lib/lxc/r2/rootfs /usr/sbin/locale-gen fr_CA.UTF8

Looks like the template needs to specify the full path for locale-gen

Changed in lxc (Ubuntu):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Simon Déziel (sdeziel) wrote :

another typo "local-gen" != "locale-gen" :)

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Actually, I was able to reproduce this before, but now I can't...

Changed in lxc (Ubuntu):
assignee: nobody → Serge Hallyn (serge-hallyn)
status: Triaged → In Progress
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

 fr_CA.UTF8 is simply not a valid locale. With

@Simon - apologies, I hadn't seen your first comment. Indeed, this bug is invalid.

Changed in lxc (Ubuntu):
status: In Progress → Invalid
Revision history for this message
James Hunt (jamesodhunt) wrote :

What about the C locale? This fails as well.

Maybe the ubuntu template could check LANG. If not set, or not in $(locale -a) or /usr/share/i18n/SUPPORTED, revert to en_US.UTF-8?

Changed in lxc (Ubuntu):
status: Invalid → Triaged
summary: - lxc-create fails if LANG != en_GB.UTF-8
+ lxc-create fails if LANG is not valid
Revision history for this message
Robie Basak (racb) wrote :

I've just hit this. C is a valid LANG, AFAIK.

Revision history for this message
Stéphane Graber (stgraber) wrote :

I think the template currently upstream has been fixed for that case.

It currently does:
    # make sure we have the current locale defined in the container
    if [ -z "$LANG" ] || echo $LANG | grep -E -q "^C(\..+)*$"; then
        chroot $rootfs locale-gen en_US.UTF-8
        chroot $rootfs update-locale LANG=en_US.UTF-8
    else
        chroot $rootfs locale-gen $LANG
        chroot $rootfs update-locale LANG=$LANG
    fi

Which should catch C and C.UTF-8 and turn them to en_US when it comes to generating the actual locale.

We may be able to cherry-pick the fix to saucy or just wait for the next upstream snapshot (should be around end of July).

Revision history for this message
Robie Basak (racb) wrote : Re: [Bug 1166841] Re: lxc-create fails if LANG is not valid

Why is en_US being hardcoded? Isn't C valid on its own? locale-gen C
doesn't make sense, but shouldn't the system work without it?

Revision history for this message
Stéphane Graber (stgraber) wrote :

In an ideal world, C.UTF-8 would be valid on its own, yes (not C as it lacks UTF-8 support).

Unfortunately we don't live in this ideal world and a lot of software unfortunately hardcode en_US.UTF-8 as their fallback locale when no other "standard" locale (as in CC.UTF-8 or CC_LL.UTF-8) is set.

That's why Ubuntu always ships with language-pack-en installed, whatever language option you may choose at install time.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

I can't tell when this was assigned to me, but it's not clear to me based on stgraber.vs.rbasak which is the right course to follow.

Is high priority right here? There is an obvious workaround iiuc, and it affects very few people.

Changed in lxc (Ubuntu):
assignee: Serge Hallyn (serge-hallyn) → nobody
Revision history for this message
Stéphane Graber (stgraber) wrote :

Sent a patch upstream to ignore the failure.

Changed in lxc (Ubuntu):
status: Triaged → Fix Committed
Changed in lxc (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.