DEV Community

nabbisen
nabbisen

Posted on • Edited on • Originally published at scqr.net

sqlcmd failed due to "locale::facet::_S_create_c_locale name not valid"

Intro

If the locale of your OS is NOT English, you might meet the error below, when the installation of sqlcmd, a Microsoft SQL Server 2017's client command line tool, has finished and you try to use it.

$ /opt/mssql-tools/bin/sqlcmd
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid
Enter fullscreen mode Exit fullscreen mode

Besides, you can see your locale this way:

$ locale
LANG=ja_JP.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
Enter fullscreen mode Exit fullscreen mode

They are my Debian's.

Solution

Let's try to solve the problem.

Case 1: With export (recommended)

$ export LANG=en_US.UTF-8
Enter fullscreen mode Exit fullscreen mode

Then run:

$ sudo locale-gen
Enter fullscreen mode Exit fullscreen mode

* Thanks to scientronic92. His comments helped me a lot.

Case 2: With locale.gen editted

Add a line to the bottom of /etc/locale.gen like this:

+ en_US.UTF-8 UTF-8
Enter fullscreen mode Exit fullscreen mode

Then run:

$ sudo locale-gen
Enter fullscreen mode Exit fullscreen mode

Outro

I hope your problem is solved after the process :)

Thank you for your reading.
Happy computing.

Top comments (3)

Collapse
 
scientronic92 profile image
scientronic92

Thank you for sharing. But I found this helpful commands:

export LANG=en_US.UTF-8
locale-gen en_US.UTF-8

It helped me with using mssql-tools.

Collapse
 
nabbisen profile image
nabbisen

Dear scientronic92,
Thank you for your comment.
That is an easier and simpler.
I have updated my post to add the link :)

Collapse
 
scientronic92 profile image
scientronic92

Thanks a lot, heddi.