Rails 4: Error when installing tiny_tds gem?

This worked for me in Ubuntu 17.04

Install wget to download packages from remote URL

$ sudo apt-get install wget 

Install dependencies

$ sudo apt-get install build-essential
$ sudo apt-get install libc6-dev

Download remote file

$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.21.tar.gz

Unzip

$ tar -xzf freetds-1.00.21.tar.gz

Configure and Run Test for the package in your system

$ cd freetds-1.00.21
$ sudo ./configure --prefix=/usr/local --with-tdsver=7.3
$ sudo make

Now, Install

$ sudo make install

Now install the gem

$ gem install tiny_tds -v '2.0.0'

If still, you cannot install the gem tiny_tds then try using sudo
$ sudo gem install tiny_tds -v '2.0.0'

Output

Building native extensions.  This could take a while...
Successfully installed tiny_tds-2.0.0
Parsing documentation for tiny_tds-2.0.0
Installing ri documentation for tiny_tds-2.0.0
Done installing documentation for tiny_tds after 1 seconds
1 gem installed

For MacOS you need additional lib installed.

brew install freetds

Looks like you don't have freetds installed on this machine:

sudo apt-get install freetds-dev

If you see the details of the freetds-dev package you will see it has the missing file sybfront.h

There is no gem that I know for freetds and building the tiny_tds gem requires it to compile. However it should be possible for you build your own version of the gem using MiniPortile.

Rather than using the normal gem install mechanism you need to clone the tiny_tds from GitHub and then build a native gem for your environment. This process will include downloading a specific version of freetds which is used to compile the gem against.

This should get you round the problem of not being able to install freetds-dev package, but does have the disadvantage that if tiny_tds gem is updated in the future you will need to repeat this process each time - you can't simply take advantage of bundle update.

The steps you need to follow are detailed here.