Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I'm trying to use the DBI rubygem to connect with a Sybase database. I've installed the dbd-sqlanywhere gem, as well as the sqlanywhere gem but when I try to connect to the Sybase DB I get Could not load SQLAnywhere DLL (LoadError)

Why am I missing the library? Isn't that what the sqlanywhere gem is supposed to be?

I tried installing the driver from this site: and it still hasn't resolved the issue.

IRB output:

$ irb
2.1.0 :001 > require 'dbi'
 => true 
2.1.0 :002 > DBI.connect('DBI:SQLAnywhere:SERVER')
LoadError: Could not load SQLAnywhere DLL
    from /home/jd/.rvm/gems/ruby-2.1.0/gems/dbd-sqlanywhere-1.0.1/lib/dbd/SQLAnywhere.rb:59:in `initialize'
    from /home/jd/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/singleton.rb:141:in `new'
    from /home/jd/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/singleton.rb:141:in `block in instance'
    from /home/jd/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/singleton.rb:139:in `synchronize'
    from /home/jd/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/singleton.rb:139:in `instance'
    from /home/jd/.rvm/gems/ruby-2.1.0/gems/dbd-sqlanywhere-1.0.1/lib/dbd/sqlanywhere/driver.rb:63:in `connect'
    from /home/jd/.rvm/gems/ruby-2.1.0/gems/dbi-0.4.5/lib/dbi/handles/driver.rb:33:in `connect'
    from /home/jd/.rvm/gems/ruby-2.1.0/gems/dbi-0.4.5/lib/dbi.rb:148:in `connect'
    from (irb):2
    from /home/jd/.rvm/rubies/ruby-2.1.0/bin/irb:11:in `<main>'
2.1.0 :003 >

asked 29 Jan '14, 13:56

JDiPierro's gravatar image

accept rate: 0%

edited 30 Jan '14, 13:11

Mark%20Culp's gravatar image

Mark Culp

Perhaps a dumb question, but have you installed SQL Anywhere on your Linux box and run the .sa_config.[c]sh script (to set the SQLA environment variables) before trying to run your ruby test?

And always a question worth asking: What version / build of SQLA are you using? (although likely not relevant here)

permanent link

answered 29 Jan '14, 14:32

Mark%20Culp's gravatar image

Mark Culp
accept rate: 41%

I have not run .sa_config.[c]sh.. I didn't see any instruction anywhere that mentioned that. Do you know where that would be located if I installed via the gem? I checked in ~/.rvm/gems/ruby-2.1.0/gems/sqlanywhere-0.1.6 and didn't see it anywhere.

Also the gem version is 0.1.6 according to that. I had tried installing SQL Anywhere 12.0.1 from the link in the question.

(29 Jan '14, 15:39) JDiPierro
Replies hidden

You need to install a version of SQL Anywhere on your linux box before you can use the SQLA Ruby driver. I.e. the ruby driver uses the client libraries included in the SQL Anywhere install to 'connect' to the database server - the ruby driver by itself cannot connect to the database server. After you run the install (from the link that you gave in your question) to lay down a copy of the Linux client libraries there will be an (for sh/bash users) and sa_config.csh (for csh/tcsh users) in the bin32/bin64 directories. source one of these scripts (depending on which shell you use) to set the required environment variables (i.e. PATH, LD_LIBRARY_PATH, and SQLANY12). HTH

(29 Jan '14, 16:15) Mark Culp

Thanks, that worked. Unfortunately then I found out I've been going down the wrong trail. I'm trying to connect to an ASE 15 server.. Going down the JDBC trail now.

(30 Jan '14, 10:09) JDiPierro

Hm, most users of this forum would not treat "choosing SQL Anywhere" as "going down the wrong trail", particularly compared to ASE:)

(30 Jan '14, 10:12) Volker Barth

Unfortunately the choice of the actual database is far from mine. I meant that I'm trying to connect to an ASE server so looking at using the SQLAnywhere driver was the wrong trail.

(30 Jan '14, 12:39) JDiPierro

Yes, I have understood that - please don't treat my ironical remark as any kind of criticism...

(31 Jan '14, 03:45) Volker Barth
showing 1 of 6 show all flat view
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 29 Jan '14, 13:56

question was seen: 3,190 times

last updated: 31 Jan '14, 03:45