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: Error: Microsoft ODBC Driver 13 for SQL Server : Can't open lib 'ODBC Driver 13 for SQL Server' : file not found #3

Closed
kenorb opened this issue Oct 24, 2017 · 7 comments

Comments

@kenorb
Copy link

kenorb commented Oct 24, 2017

Installation

brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release && brew update
# brew untap microsoft/mssql-preview # Optionally.
ACCEPT_EULA=y brew reinstall msodbcsql mssql-tools

Problem

$ sqlcmd -S localhost
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Can't open lib 'ODBC Driver 13 for SQL Server' : file not found.
$ odbcinst -j
unixODBC 2.3.4
DRIVERS............: /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini

It seems odbcinst is looking for odbcinst.ini file in the unixodbc package folder which is basically empty. Correct location:

$ brew list msodbcsql | grep odbcinst.ini$
/usr/local/Cellar/msodbcsql/13.1.9.0/odbcinst.ini

Where the one which is loaded, it's empty:

$ wc -l /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini
0 /usr/local/Cellar/unixodbc/2.3.4/etc/odbcinst.ini

Workaround

cp -v "$(brew list msodbcsql | grep odbcinst.ini$)" ~/.odbcinst.ini

Notes

  • Adding --without-registration or --no-sandbox added to brew install msodbcsql command doesn't take any effect.

Related

@v-makouz
Copy link
Contributor

I just tried the official install instructions from https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server on a clean MacOS El Capitan VM and the install succeeded with no issues and I was able use sqlcmd without any additional steps.

@kenorb
Copy link
Author

kenorb commented Oct 24, 2017

Ok, somehow reinstalling with --no-sandbox both packages helped, weird, probably I was following some old tutorial.

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
ACCEPT_EULA=y brew reinstall --no-sandbox mssql-tools msodbcsql

@jbejar
Copy link

jbejar commented Dec 19, 2017

sudo cp -v "$(brew list msodbcsql | grep odbcinst.ini$)" /etc/odbcinst.ini

I was able to get it to work, only after modifying the previously mentioned workaround to the location specified in odbcinst -j

@hktalent
Copy link

hktalent commented Aug 15, 2018

in kali linux
@jbejar @kenorb

# odbcinst -j
unixODBC 2.3.6
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

# sqlcmd -S 192.168.29.141 -U sa -P sa
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1' : file not found.

# ls -lah /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
-rwxr-xr-x 1 root root 17M Jul  3 04:34 /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1
# ls -lah /etc/odbcinst.ini
lrwxrwxrwx 1 root root 43 Aug 14 23:52 /etc/odbcinst.ini -> /opt/microsoft/msodbcsql17/etc/odbcinst.ini

# cat /etc/odbc.ini
# ls /etc/ODBCDataSources/
# cat /root/.odbc.ini

@v-makouz
Copy link
Contributor

Looks like the driver lib is owned by root, can you try running sqlcmd with sudo, as a check? And if that works try changing the owner to your user

@v-chojas
Copy link
Contributor

@hktalent This is the GitHub project for the ODBC driver on macOS, not Linux.

@VedAustin
Copy link

After having spent a couple of hours, going through every stackover flow posts related to this and trying to fix my ODBC 13 version, which was running great until I did a brew update/upgrade for a diff project, I have given up and upgraded to ver 17. There is something about the latest release from MS that just does not make it back ward compatible to ver 13. But I guess it is 2021 and it might just be better to upgrade to ver 17 .. not fun when you have to upgrade the prods as well :(

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

No branches or pull requests

6 participants