Search code examples
rubyubuntufreetdstiny-tdsruby-enterprise-edition

TinyTDS Undefined symbol dbsetluser


I've been struggling for the last couple of days with this issue and I'm out of ideas. I am working on a somewhat out of date application, in which I now need to add support for SQL Server. I have managed to get it to work locally (Ubuntu 12.04), but I am running into the following error when trying to reproduce it on Rackspace on a Ubuntu 8.04 instance:

irb > require 'rubygems'
irb > require 'tiny_tds'
irb > TinyTds::Client.new(:host => 'X.X.X.X', :user name => 'xxx', :password => 'xxx')
irb: symbol lookup error: /opt/ruby-enterprise-1.8.7-2012.02/lib/ruby/gems/1.8/gems/tiny_tds-0.6.0.rc1/lib/tiny_tds/tiny_tds.so: undefined symbol: dbsetluser

The stack I'm running is:

  • Ubuntu 8.04
  • REE 1.8.7-2012.02
  • FreeTDS 0.92.377 (compiled from source)
  • TinyTDS 0.6.0.rc1 (also tried 0.5.1)

I can successfully connect to the SQL Server using isql, which leads me to think that FreeTDS and ODBC is set up correctly. But whenever I try to connect from Ruby with TinyTds, I get the above error.

I have tried posting to the Google group for rails-sqlserver-adapter, but the forum seems moderated and my question has not yet shown up.

I'm fairly certain it has to do with TinyTds not finding the libraries (which I believe should be available somewhere), but I do not know how to achieve this.

As a last resort, I am going to start building a server from scratch with 12.04, but I would much prefer to get the existing system working.

UPDATE:

As per @Casper's suggestion I have tried connecting with odbc and now I get a different error

irb > require ‘odbc’
irb > ODBC.connect('dsn', 'username', 'password')
[unixODBC][FreeTDS][SQL Server]Unable to connect to data source`

even though I can successfully connect with isql and sqsh.

Thanks


Solution

  • It all had to do with environment variables. It seems like after installing freetds and odbc, the environment variables for FREETDSCONF, ODBCINI and ODBCSYSINI were not made available to Ruby. I had to add them to my user's .bashrc and /etc/profile as well as in my Apache config in order to get Passenger to see them (using SetEnv).

    Hope this helps someone in the future.