Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RubyODBC Cannot allocate SQLHENV

I'm trying to connect to SQL Server on Ubuntu 9.04 using Ruby. I translated and followed all the steps outlined in getting OSX talking to SQL Server from here:

http://toolmantim.com/articles/getting_rails_talking_to_sqlserver_on_osx_via_odbc

Everything is working on the FreeTDS and unixODBC end. I can see and query the database using tsql.

When I try to access the database from Ruby using IRB I get the following error:

DBI::DatabaseError : INTERN (0) [RubyODBC] Cannot allocate SQLHENV

Has anyone run into this and what can I do to solve this?

like image 272
rip747 Avatar asked Sep 14 '09 02:09

rip747


3 Answers

I started getting this error when I upgraded to Ubuntu 9.10 (Karmic Koala). Your tip regarding installation order of the Ubuntu packages didn't work for me.

It seems the fix was to manually compile ruby-odbc.

wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-dlopen
make
sudo make install
like image 68
Tim Morgan Avatar answered Nov 16 '22 07:11

Tim Morgan


System

Ubuntu 9.10 64 bit

I had to specify the odbc directory in the rubyodbc install

wget http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz
tar xzvf ruby-odbc-0.9997.tar.gz
cd ruby-odbc-0.9997
ruby extconf.rb --with-odbc-dir=/usr/lib/odbc --disable-dlopen
make
sudo make install
like image 30
JBK Avatar answered Nov 16 '22 05:11

JBK


I had the same problem.

But on Centos 5.5 not Ubuntu

Tried many forums/solutions with no joy.

The error message hints at a missing reference to unixODBC. Which was setting using LD_LIBRARY_PATH variable. Found another way to set path, by creating
/etc/ld.so.conf.d/odbc.conf. add unixODBC location to file ie /usr/local/lib. Run, sudo ldconfig.

like image 1
Mark Magnus Avatar answered Nov 16 '22 07:11

Mark Magnus