I'm trying to connect from Ruby 1.8.7 on RHEL 5 to MS SQL Server. I'm using FreeTDS and the tiny_tds RubyGem.
I got it working fine on OS X.
On Linux I installed FreeTDS and confirmed that it can connect to SQL Server from the command line no problem. And gem install tiny_tds
went fine.
However, when I deploy to Linux and try to open the Rails console I get this error:
$ script/console production
Loading production environment (Rails 2.3.5)
libsybdb.so.5: cannot open shared object file: No such file or directory - /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/tiny_tds-0.2.1/lib/tiny_tds/tiny_tds.so
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/tiny_tds-0.2.1/lib/tiny_tds/tiny_tds.so
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/opt/deployed_rails_apps/employeedata/releases/20101025214030/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/tiny_tds-0.2.1/lib/tiny_tds.rb:7
/opt/rub开发者_运维技巧y-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
etc...
I checked that this file that it says it can't find actually does exist on the filesystem...
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems \
/tiny_tds-0.2.1/lib/tiny_tds/tiny_tds.so
Any ideas how to get this to work?
How did you install FreeTDS, from source or from a distribution? I've found a lot of distribution-based installs won't install needed headers and development files, which are used by the gems to locate the needed libraries. You might look for a freetds-dev or something similar if you used the distro, and install that also.
It's also possible with a distro install that the files weren't installed in the same directory that they would be for a source installation. I've run into that a couple times with different packages. The Tiny TDS gem might have some config options to let you define where the FreeTDS files are hiding.
The extconf.rb file for tiny_tds is looking for these files:
FREETDS_LIBRARIES = ['sybdb']
FREETDS_HEADERS = ['sqlfront.h', 'sybdb.h', 'syberror.h']
Do a locate or find on your host to see if you can locate those files. According to extconf.rb the libraries should be based at /lib
or /lib/freetds
and the headers should be at /include
or /include/freetds
.
精彩评论