[GH-ISSUE #206] asciinema needs a UTF-8 native locale to run. Check the output of locale command. #764

Closed
opened 2026-03-15 10:13:02 +03:00 by kerem · 23 comments
Owner

Originally created by @ReSearchITEng on GitHub (May 15, 2017).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/206

This is a reopen of #160. This is still failing, even on asciinema 1.4 , latest in epel for centos/RH v7.

$asciinema
asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.
$locale
LANG=en_US.UTF-8
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C

SOLUTION:

export LC_ALL=${LANG}
Originally created by @ReSearchITEng on GitHub (May 15, 2017). Original GitHub issue: https://github.com/asciinema/asciinema/issues/206 This is a reopen of #160. This is still failing, even on asciinema 1.4 , latest in epel for centos/RH v7. ```bash $asciinema asciinema needs a UTF-8 native locale to run. Check the output of `locale` command. $locale LANG=en_US.UTF-8 LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C" LC_PAPER="C" LC_NAME="C" LC_ADDRESS="C" LC_TELEPHONE="C" LC_MEASUREMENT="C" LC_IDENTIFICATION="C" LC_ALL=C ``` **SOLUTION:** ```bash export LC_ALL=${LANG} ```
kerem closed this issue 2026-03-15 10:13:08 +03:00
Author
Owner

@ku1ik commented on GitHub (May 16, 2017):

As I mentioned in #160, it's enough to only set LC_CTYPE="*.UTF-8". If you do it then you can set LANG and other as you wish.

<!-- gh-comment-id:301712675 --> @ku1ik commented on GitHub (May 16, 2017): As I mentioned in #160, it's enough to only set `LC_CTYPE="*.UTF-8"`. If you do it then you can set `LANG` and other as you wish.
Author
Owner

@cmoulliard commented on GitHub (Oct 2, 2018):

This trick doesn't work on Macos

$ export LC_CTYPE="*.UTF-8"
$ export LANG=
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

$ asciinema
asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.
<!-- gh-comment-id:426285074 --> @cmoulliard commented on GitHub (Oct 2, 2018): This trick doesn't work on Macos ``` $ export LC_CTYPE="*.UTF-8" $ export LANG= $ locale LANG= LC_COLLATE="C" LC_CTYPE="C" LC_MESSAGES="C" LC_MONETARY="C" LC_NUMERIC="C" LC_TIME="C" LC_ALL="C" $ asciinema asciinema needs a UTF-8 native locale to run. Check the output of `locale` command. ```
Author
Owner

@ku1ik commented on GitHub (Nov 16, 2018):

I think I wasn't clear enough, sorry about that. What I meant by export LC_CTYPE="*.UTF-8" is export LC_CTYPE="en_US.UTF-8" (or other specific locale). * was just a thought shortcut :)

<!-- gh-comment-id:439538007 --> @ku1ik commented on GitHub (Nov 16, 2018): I think I wasn't clear enough, sorry about that. What I meant by `export LC_CTYPE="*.UTF-8"` is `export LC_CTYPE="en_US.UTF-8"` (or other specific locale). `*` was just a thought shortcut :)
Author
Owner

@ghost commented on GitHub (Dec 9, 2018):

This bug is affecting a musl-based stack, while @sickill 's fix does not solve the problem.

<!-- gh-comment-id:445500408 --> @ghost commented on GitHub (Dec 9, 2018): This bug is affecting a musl-based stack, while @sickill 's fix does not solve the problem.
Author
Owner

@ku1ik commented on GitHub (Dec 10, 2018):

I merged #302 recently. Is this going to solve it for musl-based stack you think @lifranc ?

<!-- gh-comment-id:445729621 --> @ku1ik commented on GitHub (Dec 10, 2018): I merged #302 recently. Is this going to solve it for musl-based stack you think @lifranc ?
Author
Owner

@arielf commented on GitHub (Jan 29, 2019):

Hello @sickill

Thanks for writing this cool software.

Seems like this issue still exists in latest (fresh clone 2019-01-29, Ubuntu 18.04):

$ git clone https://github.com/asciinema/asciinema
$ cd asciinema
$ git checkout develop
Already on 'develop'
Your branch is up to date with 'origin/develop'.
$ env LC_CTYPE="en_US.UTF-8" python3 -m asciinema  rec
asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command.

When I set LC_ALL=${LANG} (was C) - the problem goes away.

I happen to have LC_ALL=C which should behave similar to ASCII.
If ASCII is allowed, perhaps C could be allowed as well?

<!-- gh-comment-id:458682213 --> @arielf commented on GitHub (Jan 29, 2019): Hello @sickill Thanks for writing this cool software. Seems like this issue still exists in latest (fresh clone 2019-01-29, Ubuntu 18.04): ``` $ git clone https://github.com/asciinema/asciinema $ cd asciinema $ git checkout develop Already on 'develop' Your branch is up to date with 'origin/develop'. $ env LC_CTYPE="en_US.UTF-8" python3 -m asciinema rec asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command. ``` When I set `LC_ALL=${LANG}` (was `C`) - the problem goes away. I happen to have `LC_ALL=C` which should behave similar to ASCII. If ASCII is allowed, perhaps `C` could be allowed as well?
Author
Owner

@just4t commented on GitHub (Jan 29, 2019):

No doubt this should be fixed within the install script as some Ubuntu 18.04 LTS provider provided images don't have locale set by default...

  • Try to fix your locale as follows:
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
reboot

Then try to install again. Hope this helps.

<!-- gh-comment-id:458684756 --> @just4t commented on GitHub (Jan 29, 2019): No doubt this should be fixed within the install script as some Ubuntu 18.04 LTS provider provided images don't have _locale_ set by default... - Try to fix your _locale_ as follows: ``` locale-gen en_US.UTF-8 update-locale LANG=en_US.UTF-8 reboot ``` Then try to install again. Hope this helps.
Author
Owner

@ghost commented on GitHub (Jan 30, 2019):

@sickill My musl infra borked and I then took an oath never to leave nixOS again. But we started an early fork to rebase nixOS on musl although I could take months before the switch we'll be able to test then. The whole locale situation is rather ugly right now so we'll look for a sane solution.

<!-- gh-comment-id:458801850 --> @ghost commented on GitHub (Jan 30, 2019): @sickill My musl infra borked and I then took an oath never to leave nixOS again. But we started an early fork to rebase nixOS on musl although I could take months before the switch we'll be able to test then. The whole locale situation is rather ugly right now so we'll look for a sane solution.
Author
Owner

@p-alik commented on GitHub (Feb 28, 2019):

setting LC_ALL solves the issue on NixOS also.

$ nixos-version 
18.09.2266.aabc61049c0 (Jellyfish)

$ asciinema --version                                                         
asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.

$ LC_ALL="en_US.UTF-8" asciinema --version                                                                                                  
asciinema 2.0.1
<!-- gh-comment-id:468192317 --> @p-alik commented on GitHub (Feb 28, 2019): setting `LC_ALL` solves the issue on NixOS also. ```bash $ nixos-version 18.09.2266.aabc61049c0 (Jellyfish) $ asciinema --version asciinema needs a UTF-8 native locale to run. Check the output of `locale` command. $ LC_ALL="en_US.UTF-8" asciinema --version asciinema 2.0.1 ```
Author
Owner

@ku1ik commented on GitHub (Mar 17, 2019):

2.0.2 was released with #302 fix. It now works fine on C and *.UTF-8.

In case you run env LC_CTYPE="en_US.UTF-8" asciinema ... and it still doesn't work, it could be that your OS doesn't have local files generated properly, and you may need to uncomment it in /etc/locale.gen, then run sudo locale-gen.

<!-- gh-comment-id:473658629 --> @ku1ik commented on GitHub (Mar 17, 2019): 2.0.2 was released with #302 fix. It now works fine on `C` and `*.UTF-8`. In case you run `env LC_CTYPE="en_US.UTF-8" asciinema ...` and it still doesn't work, it could be that your OS doesn't have local files generated properly, and you may need to uncomment it in `/etc/locale.gen`, then run `sudo locale-gen`.
Author
Owner

@ku1ik commented on GitHub (Mar 17, 2019):

The check for character encoding happens here: https://github.com/asciinema/asciinema/blob/develop/asciinema/main.py#L53
It uses Python's built-in locale module.

@lifranc I'm not familiar with musl too much, and how musl-based Python builds implement the locale support, but I'm happy to add necessary changes to make it work under nixOS (or musl in general).

<!-- gh-comment-id:473658890 --> @ku1ik commented on GitHub (Mar 17, 2019): The check for character encoding happens here: https://github.com/asciinema/asciinema/blob/develop/asciinema/__main__.py#L53 It uses Python's built-in `locale` module. @lifranc I'm not familiar with musl too much, and how musl-based Python builds implement the locale support, but I'm happy to add necessary changes to make it work under nixOS (or musl in general).
Author
Owner

@ghost commented on GitHub (Mar 18, 2019):

@sickill nixOS doesnt use musl - our fork of it will. I'm not testing the musl stack currently, busy with other things. Musl doesnt have local-gen, which I fundamentally agree with. But there's a project, which I haven't testetd, to add the funcionality here - https://gitlab.com/rilian-la-te/musl-locales

<!-- gh-comment-id:473756330 --> @ghost commented on GitHub (Mar 18, 2019): @sickill nixOS doesnt use musl - our fork of it will. I'm not testing the musl stack currently, busy with other things. Musl doesnt have `local-gen`, which I fundamentally agree with. But there's a project, which I haven't testetd, to add the funcionality here - https://gitlab.com/rilian-la-te/musl-locales
Author
Owner

@frak0d commented on GitHub (Jan 29, 2022):

Can't we just have a force override flag ?

I have tried everything but it still complains about locale.

<!-- gh-comment-id:1024947897 --> @frak0d commented on GitHub (Jan 29, 2022): Can't we just have a force override flag ? I have tried everything but it still complains about locale.
Author
Owner

@ku1ik commented on GitHub (Feb 6, 2022):

The reason asciinema requires UTF-8 charset is so we don't need to deal with countless different char encodings when replaying the recording. If the charset is set properly for your shell then all programs you run inside asciinema session will output UTF-8. If we had a flag that overrides this check it would mean the output asciinema captures is not guaranteed to be UTF-8, which in turn could lead to garbage being saved in the output asciicast file. But I guess we could have such force override option that would be marked as "on your own risk".

<!-- gh-comment-id:1030861270 --> @ku1ik commented on GitHub (Feb 6, 2022): The reason asciinema requires UTF-8 charset is so we don't need to deal with countless different char encodings when replaying the recording. If the charset is set properly for your shell then all programs you run inside asciinema session will output UTF-8. If we had a flag that overrides this check it would mean the output asciinema captures is not guaranteed to be UTF-8, which in turn could lead to garbage being saved in the output asciicast file. But I guess we could have such force override option that would be marked as "on your own risk".
Author
Owner

@upstream-dmahlberg commented on GitHub (Feb 6, 2022):

I'm experiencing the same issue. Running on Manjaro with the Snap package. A flag would be awesome.

<!-- gh-comment-id:1030862127 --> @upstream-dmahlberg commented on GitHub (Feb 6, 2022): I'm experiencing the same issue. Running on Manjaro with the Snap package. A flag would be awesome.
Author
Owner

@mathieu-aubin commented on GitHub (Jun 9, 2022):

Try the simplest easiest solution of setting on the command line BEFORE the program call... as in;

LC_ALL=en_US.UTF-8 asciinema rec -c 'locale'

Set a shell alias for easy going

@sickill BTW, this wont upload complaining of duration invalid - am i just in a bug time or is this relevant and an actual potential issue?

<!-- gh-comment-id:1150966641 --> @mathieu-aubin commented on GitHub (Jun 9, 2022): Try the simplest easiest solution of setting on the command line BEFORE the program call... as in; `LC_ALL=en_US.UTF-8 asciinema rec -c 'locale'` Set a shell alias for easy going @sickill BTW, this wont upload complaining of duration invalid - am i just in a bug time or is this relevant and an actual potential issue?
Author
Owner

@wongjiahau commented on GitHub (Mar 7, 2023):

No doubt this should be fixed within the install script as some Ubuntu 18.04 LTS provider provided images don't have locale set by default...

  • Try to fix your locale as follows:
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
reboot

Then try to install again. Hope this helps.

This works in my Ubuntu docker container as well, thanks.

<!-- gh-comment-id:1457709831 --> @wongjiahau commented on GitHub (Mar 7, 2023): > No doubt this should be fixed within the install script as some Ubuntu 18.04 LTS provider provided images don't have _locale_ set by default... > > * Try to fix your _locale_ as follows: > > ``` > locale-gen en_US.UTF-8 > update-locale LANG=en_US.UTF-8 > reboot > ``` > > Then try to install again. Hope this helps. This works in my Ubuntu docker container as well, thanks.
Author
Owner

@ku1ik commented on GitHub (Mar 7, 2023):

At this point I don't think there's any remaining bug in asciinema with regards to locale handling (requirement of UTF-8 charset is desired behavior), so I'm closing it.

<!-- gh-comment-id:1457817295 --> @ku1ik commented on GitHub (Mar 7, 2023): At this point I don't think there's any remaining bug in asciinema with regards to locale handling (requirement of UTF-8 charset is desired behavior), so I'm closing it.
Author
Owner

@fuzzko commented on GitHub (May 3, 2023):

The issue still going.

I have asciinema installed via package manager (Paru) in Arch Linux (Proot). Apparently the error about Locale being not UTF-8 or ASCII is happening in my Arch Linux.

~/project/startmux                                                   main ?1 3s 14:26:2
=> asciinema
asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command.

I've also tried LC_ALL="en_US.UTF-8" and others possible fixes, still it doesn't affect anything.

~/project/startmux                                                      main ?1 14:28:2
=> LC_ALL=en_US.UTF-8 asciinema
asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command.
<!-- gh-comment-id:1532505670 --> @fuzzko commented on GitHub (May 3, 2023): The issue still going. I have asciinema installed via package manager (Paru) in Arch Linux (Proot). Apparently the error about Locale being not UTF-8 or ASCII is happening in my Arch Linux. ``` ~/project/startmux main ?1 3s 14:26:2 => asciinema asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command. ``` I've also tried `LC_ALL="en_US.UTF-8"` and others possible fixes, still it doesn't affect anything. ``` ~/project/startmux main ?1 14:28:2 => LC_ALL=en_US.UTF-8 asciinema asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command. ```
Author
Owner

@ku1ik commented on GitHub (May 4, 2023):

@UrNightmaree What asciinema version do you have? What's the output of LC_ALL=en_US.UTF-8 locale?

<!-- gh-comment-id:1534287121 --> @ku1ik commented on GitHub (May 4, 2023): @UrNightmaree What asciinema version do you have? What's the output of `LC_ALL=en_US.UTF-8 locale`?
Author
Owner

@fuzzko commented on GitHub (May 6, 2023):

@sickill Sorry for long response, here's the output.

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
<!-- gh-comment-id:1537191710 --> @fuzzko commented on GitHub (May 6, 2023): @sickill Sorry for long response, here's the output. ``` locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_MESSAGES to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=en_US.UTF-8 ```
Author
Owner

@ku1ik commented on GitHub (May 6, 2023):

@UrNightmaree yeah, so you don't have en_US.UTF-8 locale generated on your system. See here https://github.com/asciinema/asciinema/issues/206#issuecomment-473658629

<!-- gh-comment-id:1537204381 --> @ku1ik commented on GitHub (May 6, 2023): @UrNightmaree yeah, so you don't have `en_US.UTF-8` locale generated on your system. See here https://github.com/asciinema/asciinema/issues/206#issuecomment-473658629
Author
Owner

@fuzzko commented on GitHub (May 6, 2023):

@sickill Thank you, that fixed the issue. 😄

<!-- gh-comment-id:1537220912 --> @fuzzko commented on GitHub (May 6, 2023): @sickill Thank you, that fixed the issue. 😄
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#764
No description provided.