# Connecting to MS SQL server from OSX

**URL:** <https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227>\
**Category:** rubyonrails-talk\
**Created:** [July 22, 2008, 8:36pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227 "2008-07-22T20:36:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom10](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@Tom10](https://discuss.rubyonrails.org/u/Tom10)\
**Post date:** [July 22, 2008, 8:36pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/1 "2008-07-22T20:36:00Z")

</div>

This has been a long painful day and I am hoping someone can help. I am trying to get my Rails application running on Mac/Leopard to connect to a Microsoft SQL server. I have followed the instructions at [http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnOSX](http://wiki.rubyonrails.org/rails/pages/HowtoConnectToMicrosoftSQLServerFromRailsOnOSX).

Everything appears to work until I get to IRB. In other words, I can use iodbc and tsql with no problem. But when I go into IRB and run require 'dbi', I get the following error:

LoadError: no such file to load -- dbi &nbsp;&nbsp;from /Library/Ruby/Site/1.8/rubygems/custom\_require.rb:27:in `gem_original_require' &nbsp;&nbsp;from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require' &nbsp;&nbsp;from (irb):1

According to MacPorts, I have installed rb-dbi @0.1.1\_1+dbd\_odbc (active) rb-odbc @0.9995\_0 (active)

What am I missing?

Thanks! Tom

---

<div class="post-metadata">

**Author:** ![hank](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@hank](https://discuss.rubyonrails.org/u/hank)\
**Post date:** [July 22, 2008, 10:21pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/2 "2008-07-22T22:21:17Z")

</div>

I have tried all those sites this week myself, the best solution was found at the following link: [http://installingcats.com/2007/12/13/mysql-ruby-gem-install-problem-on-mac-os-x-leopard/](http://installingcats.com/2007/12/13/mysql-ruby-gem-install-problem-on-mac-os-x-leopard/) once this was finished, I was able to go into IRB and type require"MySql" and all worked fine.

---

<div class="post-metadata">

**Author:** ![bphogan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/bphogan/32/4186_2.png) [@bphogan](https://discuss.rubyonrails.org/u/bphogan)\
**Post date:** [July 22, 2008, 10:33pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/3 "2008-07-22T22:33:56Z")

</div>

This should help you:

See [http://www.napcsweb.com/blog/2007/03/08/15/](http://www.napcsweb.com/blog/2007/03/08/15/) to see how I did it. (I try to keep this as up-to-date as I can.)

---

<div class="post-metadata">

**Author:** ![bphogan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/bphogan/32/4186_2.png) [@bphogan](https://discuss.rubyonrails.org/u/bphogan)\
**Post date:** [July 23, 2008, 1:36am UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/4 "2008-07-23T01:36:36Z")

</div>

@hank:

MySQL != Microsoft SQL Server.

However, that link is very helpful for getting around the MySQL gem issues.

---

<div class="post-metadata">

**Author:** ![Tom10](https://avatars.discourse-cdn.com/v4/letter/t/cc9497/32.png) [@Tom10](https://discuss.rubyonrails.org/u/Tom10)\
**Post date:** [July 23, 2008, 2:21pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/5 "2008-07-23T14:21:10Z")

</div>

Brian,

Thanks for your post. I followed your tutorial and got the require 'dbi' from IRB to work, but when I try to use a brand new rails application with a database.yml set up with the correct Microsoft SQL connection information, I get the following error:

/Library/Ruby/Site/1.8/rubygems.rb:142:in `activate'💎:Exception: can't activate activerecord (= 1.15.6, runtime), already activated activerecord-2.1.0

Anyone have any insight into this?

Thanks, Tom

---

<div class="post-metadata">

**Author:** ![savant](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@savant](https://discuss.rubyonrails.org/u/savant)\
**Post date:** [July 23, 2008, 4:43pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/6 "2008-07-23T16:43:07Z")

</div>

I know what it is, although I can't tell you how to fix it.

A gem is specifying that it needs activerecord version 1.15.6. At this point this requirement is discovered, Rails tries to activate that gem. However, your setup is already running activerecord version 2.1.0. Rails can't activate two versions of the same gem, hence the error.

Generally, this happens when a newer version of a gem is installed. In this case, for example, I'd expect to see:

/Library/Ruby/Site/1.8/rubygems.rb:142:in `activate'💎:Exception: can't activate activerecord (= 2.1.0, runtime), already activated activerecord-1.15.6

In that case, the fix that has worked for me is gem cleanup, which removes older versions of duplicated gems. If you did that, I'm assuming that activerecord 1.15.6 would be removed. I'm not sure what that would do, since you clearly have a gem that is trying to activate 1.15.6 instead of the other way 'round.

---

<div class="post-metadata">

**Author:** ![bphogan](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/bphogan/32/4186_2.png) [@bphogan](https://discuss.rubyonrails.org/u/bphogan)\
**Post date:** [July 24, 2008, 5:49am UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/7 "2008-07-24T05:49:11Z")

</div>

Rails 2.x dropped native support for SQL Server. Add it back.

sudo gem instal activerecord-sqlserver-adapter --source=[http://www.rubyonrails.org](http://www.rubyonrails.org)

---

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [November 19, 2008, 6:35pm UTC](https://discuss.rubyonrails.org/t/connecting-to-ms-sql-server-from-osx/32227/8 "2008-11-19T18:35:09Z")

</div>

> sudo gem instal activerecord-sqlserver-adapter --source= [http://www.rubyonrails.org](http://www.rubyonrails.org)

source needs to be: [http://gems.rubyonrails.org](http://gems.rubyonrails.org) in order to instal the activerecord-sqlserver-adapter.
