Attempting to install ruby-odbc gem on Debian/Ubuntu results in the following error;
"ERROR: sql.h not found"
This happens on OSX too so brew to the rescue:
brew install unixodbc
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/unixodbc/2.3.2_1
(or whatever your path to ODBC dir as installed by Brew)
gem install ruby-odbc -- --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.9_1
Install the unixodbc-dev package, then try the gem install again
sudo apt-get install unixodbc-dev
gem install ruby-odbc
On mac, the gem couldn't find the native package.
brew install unixodbc
See the path where it is installed with:
brew list unixodbc
And you'll get something like:
/opt/homebrew/Cellar/unixodbc/2.3.11/.bottle/etc/ (2 files) /opt/homebrew/Cellar/unixodbc/2.3.11/bin/dltest /opt/homebrew/Cellar/unixodbc/2.3.11/bin/isql /opt/homebrew/Cellar/unixodbc/2.3.11/bin/iusql /opt/homebrew/Cellar/unixodbc/2.3.11/bin/odbc_config /opt/homebrew/Cellar/unixodbc/2.3.11/bin/odbcinst /opt/homebrew/Cellar/unixodbc/2.3.11/bin/slencheck /opt/homebrew/Cellar/unixodbc/2.3.11/include/unixODBC/ (2 files) /opt/homebrew/Cellar/unixodbc/2.3.11/include/ (11 files) /opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbc.2.dylib /opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbccr.2.dylib /opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbcinst.2.dylib /opt/homebrew/Cellar/unixodbc/2.3.11/lib/pkgconfig/ (3 files) /opt/homebrew/Cellar/unixodbc/2.3.11/lib/ (6 other files) /opt/homebrew/Cellar/unixodbc/2.3.11/share/man/ (8 files)
apply that output to
gem install ruby-odbc -- --with-odbc-dir=[path to unixodbc]
Example:
gem install ruby-odbc -- --with-odbc-dir=/usr/local/Cellar/unixodbc/2.3.11
This answer worked for me, thanks to @tombeynon very much. It is also simpler than the previous and could be implemented in a docker container.
apt-get install unixodbc-dev
gem install odbc_adapter
sudo
and installed a different package. A comment on their answer like "For docker containers, remember to remove sudo and gem install odbc_adapter
instead" would have been more suitable
Jun 25, 2020 at 11:24