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

Table of contents

Intro Intro

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

console
$ /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:

console
$ 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 (opens in a new tab)’s.

Solution Solution

Let’s try to solve the problem.

console
$ export LANG=en_US.UTF-8

Then run:

console
$ sudo locale-gen

* Thanks to scientronic92 (opens in a new tab). His comments (opens in a new tab) helped me a lot.

Case 2: With locale.gen editted Case 2: With locale.gen editted

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

diff
+ en_US.UTF-8 UTF-8

Then run:

console
$ sudo locale-gen

Outro Outro

I hope your problem is solved after the process :)

Thank you for your reading. Happy computing.

More on: Run a database on your server

Scqr [secureal]

Scqr [secureal]: the engineering practice of Reflerd Inc. (opens in a new tab)

Comments and feedback are welcome.