# Totally stumped

**URL:** <https://www.ruby-forum.com/t/totally-stumped/139341>\
**Category:** Ruby\
**Created:** [June 3, 2008, 2:49am UTC](https://www.ruby-forum.com/t/totally-stumped/139341 "2008-06-03T02:49:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 2:49am UTC](https://www.ruby-forum.com/t/totally-stumped/139341/1 "2008-06-03T02:49:35Z")

</div>

Hi, everyone,  
I’m have this issue where I’m using FreeTDS and unixODBC to connect to  
an  
SQL Server database. The weird thing is that it works when I’m logged  
in,  
running things from irb. However, if I start a process using cron, it  
doesn’t work. I’ve compared my PATH and $: in both environments and  
they’re  
the same … are there any other things that might be different between  
the  
cron environment and my login environment that may affect Ruby?

Thanks!

jw

---

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 3:11am UTC](https://www.ruby-forum.com/t/totally-stumped/139341/2 "2008-06-03T03:11:50Z")

</div>

jenny w wrote:

> Hi, everyone,  
> I’m have this issue where I’m using FreeTDS and unixODBC to connect to an  
> SQL Server database. The weird thing is that it works when I’m logged in,  
> running things from irb. However, if I start a process using cron, it  
> doesn’t work. I’ve compared my PATH and $: in both environments and they’re  
> the same … are there any other things that might be different between the  
> cron environment and my login environment that may affect Ruby?

What user is the cron task? What permissions?

---

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 4:44am UTC](https://www.ruby-forum.com/t/totally-stumped/139341/3 "2008-06-03T04:44:17Z")

</div>

On Mon, Jun 2, 2008 at 6:10 PM, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What user is the cron task? What permissions?

Same user is running cron. That’s what makes this so perplexing. If I  
run  
the job as that user from the command-line it works; if I run it through  
cron as the same user, it doesn’t. I get:

DBI::DatabaseError (IM002 (0) [unixODBC][Driver Manager]Data source name  
not  
found, and no default driver specified):  
/usr/local/lib/site\_ruby/1.8/DBD/ODBC/ODBC.rb:96:in `connect' /usr/local/lib/site_ruby/1.8/dbi/dbi.rb:584:in `connect’  
/usr/local/lib/site\_ruby/1.8/dbi/dbi.rb:384:in `connect’

Thanks!

---

<div class="post-metadata">

**Author:** ![jenny\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@jenny\_w](https://www.ruby-forum.com/u/jenny_w)\
**Post date:** [June 3, 2008, 5:34am UTC](https://www.ruby-forum.com/t/totally-stumped/139341/4 "2008-06-03T05:34:33Z")

</div>

Ack! Just figured out that the problem happens outside of Ruby, too.  
Once I  
realized I could reproduce the issue with isql, I realized I was missing  
the  
FREETDSCONF environment variable. D’oh!
