Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlcmd ungraceful termination without en_US.UTF-8 UTF-8 locale #163

Open
mloskot opened this issue Sep 28, 2017 · 7 comments
Open

sqlcmd ungraceful termination without en_US.UTF-8 UTF-8 locale #163

mloskot opened this issue Sep 28, 2017 · 7 comments

Comments

@mloskot
Copy link

mloskot commented Sep 28, 2017

First, this report is not just about issue with mssql-docker but I suspect it is related to about mssql-tools for Linux in general, more specifically the sqlcmd. (Not sure where would be better and more accessible by others place to report it.)

I run docker container based on ubuntu:latest image and I install the mssql-tools in order to be able to run sqlcmd (I'm connecting to SQL Server in separate container).

Here is my Dockerfile

RUN apt-get -qy update && apt-get -qy install --no-upgrade --no-install-recommends \
        apt-transport-https \
        apt-utils \
        curl \
        software-properties-common

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN add-apt-repository "$(curl -s https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"

RUN ACCEPT_EULA=Y apt-get -qy install --no-upgrade --no-install-recommends \
        msodbcsql \
        mssql-tools \
        unixodbc-dev

RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

Then I do docker exec -it bash and BANG!

root@2531848bc8e4:/# /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

The SQL Server installation docs do not mention anything about specific locale required.

The only source of any hints is the Dockerfile-s like https://github.com/Microsoft/mssql-docker/blob/master/oss-drivers/msphpsql/Dockerfile, which contain:

# install necessary locales
RUN apt-get install -y locales \
    && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
    && locale-gen

If digs deeper, one can find this comment #8 (comment) for the seemingly unrelated issue #8

Clearly, this is a bug in the implementation of the mssql-tools, specifically the sqlcmd which should detect it runs in environment with incompatible locale and, obviously, print an informative message, not just terminate.

@fenchu
Copy link

fenchu commented Feb 8, 2018

You need to have "en_US.UTF-8" along with your other locale:

Only "nb_NO.UTF-8" fails:

root@011bfaee687f:/test/sensiotools/sensiotools# /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

^C^Z
[1]+  Venter                  /opt/mssql-tools/bin/sqlcmd
root@011bfaee687f:/test/sensiotools/sensiotools# locale
LANG=nb_NO.UTF-8
LANGUAGE=
LC_CTYPE="nb_NO.UTF-8"
LC_NUMERIC="nb_NO.UTF-8"
LC_TIME="nb_NO.UTF-8"
LC_COLLATE="nb_NO.UTF-8"
LC_MONETARY="nb_NO.UTF-8"
LC_MESSAGES="nb_NO.UTF-8"
LC_PAPER="nb_NO.UTF-8"
LC_NAME="nb_NO.UTF-8"
LC_ADDRESS="nb_NO.UTF-8"
LC_TELEPHONE="nb_NO.UTF-8"
LC_MEASUREMENT="nb_NO.UTF-8"
LC_IDENTIFICATION="nb_NO.UTF-8"
LC_ALL=
root@011bfaee687f:/test/sensiotools/sensiotools# dpkg-query -l mssql-tools
Ønsket=Ukjent/Installer/Fjern/Rens ut/Hold tilbake
| Status=Ikke/Inst/Oppsettsfiler/Ikke pakket ut/HalvT-satt-opp/Halvt-inst/Ut-ventende
|/ Feil?=(ingen)/Må inst. på nytt (Status,Feil: versalar=dumt)
||/ Navn                                          Versjon                     Architecture                Beskrivelse
+++-=============================================-===========================-===========================-===============================================================================================
ii  mssql-tools                                   14.0.6.0-1                  amd64                       Tools for Microsoft(R) SQL Server(R)

I add "en_US.UTF-8" along with my previous one it works:

root@011bfaee687f:/test/sensiotools/sensiotools# echo "nb_NO.UTF-8 UTF-8" > /etc/locale.gen
root@011bfaee687f:/test/sensiotools/sensiotools# echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
root@011bfaee687f:/test/sensiotools/sensiotools# locale-gen
Generating locales (this might take a while)...
  en_US.UTF-8... done
  nb_NO.UTF-8... done
Generation complete.
root@011bfaee687f:/test/sensiotools/sensiotools# /opt/mssql-tools/bin/sqlcmd
Microsoft (R) SQL Server Command Line Tool
Version 13.1.0007.0 Linux
Copyright (c) 2012 Microsoft. All rights reserved.
:

@tyeth
Copy link

tyeth commented Mar 27, 2018

Thanks, I had mine unset on a vps for ages and never thought it an issue. To be honest it should cope without. Most linux things are able to assume a default or cope without entirely. Warnings aplenty mind you as I've seen many times in the past with other linux build processes etc.

@theccalderon
Copy link

fenchu's answer solved the issue for me.

@bizmate
Copy link

bizmate commented Jun 29, 2018

My locale is set but the problem is still present

@theccalderon
Copy link

@bizmate did you add:

echo "nb_NO.UTF-8 UTF-8" > /etc/locale.gen
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen

then run locale-gen and the issue is still there?

@bizmate
Copy link

bizmate commented Jun 29, 2018

@ccalderon911217 i just realised this is for docker, so this must be for a specific version of linux. I am seeing the problem on a centos7 VM (not on FROM ubuntu:16.04) where

[vagrant@localhost ~]$ localectl status
   System Locale: LANG=en_GB.utf8
       VC Keymap: uk
      X11 Layout: gb

/etc/locale.gen does not exist and have only one locale

[vagrant@localhost ~]$ localectl list-locales
en_GB.utf8

@theccalderon
Copy link

@bizmate yeah this is for ubuntu:latest I believe so I would be different for a centOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants