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

nabbisen - May 23 '19 - - Dev Community

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .