rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
606 stars 190 forks source link

TinyTds::Error (Adaptive Server connection failed) on Rails 6.0.3.1 / rbenv #472

Closed jbwl closed 4 years ago

jbwl commented 4 years ago

I have a multi-Ruby system with rbenv. The app with said error runs on Rails 6 / Ruby 2.7.1 / tiny_tds 2.12

I have checked these bullet points:

I installed FreeTDS 1.1.42 from source with configure, make, sudo make install

Yes, see below.

Environment

Operating System

Ubuntu 20.04 LTS

TinyTDS Version and Information

tsql-ttds -C                                                                                                                                                                                                                                                 [TinyTds][v2.1.2][tsql]: /usr/local/bin/tsql
Compile-time settings (established with the "configure" script)
                            Version: freetds v1.1.42
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: auto
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: no
                            OpenSSL: yes
                             GnuTLS: no
                               MARS: yes

FreeTDS Version 1.1.42

Description

When I type "tsql -C" anywhere, I am getting the following:

rbenv: tsql: command not found

The `tsql' command exists in these Ruby versions:
  2.3.1

this is a tsql from another Ruby environment which I do not use for this Rails app.

The correct binary is the one FreeTDS has installed tsql into /usr/local/bin, and works from the command line (output of tsql -C see below). I can also connect to a server using that tsql from the command line, and do queries etc.

But I cannot connect in the Rails app using tiny_tds:

TinyTds::Error (Adaptive Server connection failed)

Inside my 2.7.1 bundle with tiny_tds, I do not have a tsql command, only a tsql-ttds command which correctly points to /usr/local/bin/tsql

I have a hunch that this error is caused by the tiny_tds gem wants to call the "tsql" command instead of the "tsql-ttds" command to connect, and cannot find it because of above situation. Is this a PATH var issue, if yes, please let me know where to set the path so the tiny_tds gem finds the tsql bin.

If there is a way to get a more verbose error description from tiny_tds, that could help as well.

jbwl commented 4 years ago

Recompiling FreetTDS with setting TDS version to 7.1 fixed the issue.