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

created
( modified )
@nabbisen

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

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=

They are my Debian’s.

Solution

Let’s try to solve the problem.

$ export LANG=en_US.UTF-8

Then run:

$ sudo locale-gen

* 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

Then run:

$ sudo locale-gen

Outro

I hope your problem is solved after the process :)

Thank you for your reading. Happy computing.

Series

MS SQL Server 2017 on Debian 9
  1. Microsoft SQL Server 2017 on Debian 9
  2. Microsoft SQL Server Client 2017 on Debian 9
  3. sqlcmd failed due to "locale::facet::_S_create_c_locale name not valid"

Comments or feedbacks are welcomed and appreciated.