Webrick source environment variables

105 views
Skip to first unread message

mikelb

unread,
Aug 10, 2010, 12:58:42 AM8/10/10
to SQL Anywhere Web Development
Hey,

I now have SQLAnywhere working *very* sweetly with Ruby on Rails
through Apache using the gem, and thanks to Eric's help.

Now I need to get it working with Webrick so that I can do some
development. Though, I'm getting the same error I was initially with
Apache:

Could not load SQLAnywhere DBCAPI library

This (in Apache) was due to the environment variables not getting
sourced. I put that (on my dev box) in my /etc/init.d/apache2. But
I'm not sure where to put it for Webrick....

Any help would be awesome and appreciated! (A squared).

Thanks!

mikelb

mikelb

unread,
Aug 10, 2010, 10:47:35 AM8/10/10
to SQL Anywhere Web Development
OK, So it's not the environment variables. I've printed them out, and
they appear to be in order.

Anyone have any thoughts about the error?

Many thanks!
mikelb

Eric Farrar

unread,
Aug 13, 2010, 2:18:03 PM8/13/10
to SQL Anywhere Web Development
Hey Mikelb,

Can you tell me how and where you are printing out the environment
variables?

Thanks,

- Eric

mikelb

unread,
Aug 16, 2010, 9:10:51 PM8/16/10
to SQL Anywhere Web Development
Shoot. I don't remember! Somehow in some debug session...

BUT, actually, I've changed to using the Mongrel server (and still get
the same error). I'd like to use it for runtime debugging. Where can
I start?

Thanks, Eric!

Michael

erfa...@gmail.com

unread,
Aug 17, 2010, 5:04:26 PM8/17/10
to SQL Anywhere Web Development
Hey Michael,

Working on getting my mongrel server up and running. Will post some
answers soon.

- Eric

Michael Bahnmiller

unread,
Aug 17, 2010, 5:05:26 PM8/17/10
to sql-anywhere-w...@googlegroups.com
Heh. Thanks Eric!

PS. I'm on Ubuntu, you?

Eric Farrar

unread,
Aug 18, 2010, 11:56:03 AM8/18/10
to SQL Anywhere Web Development
Hi Michael,

Yes, I am on Ubuntu as well (10.04.1 to be precise). I am using a
setup with SQL Anywhere 12.0.0.2483 and Rails 2.3.8

I have created a sample app and am using the Mongrel server fine
(starting it both through script/server and mongrel_start). Can you
post what you type to start it, and where the error appears?

Thanks,

- Eric

On Aug 17, 5:05 pm, Michael Bahnmiller <songsofdistantea...@gmail.com>
wrote:
> Heh.  Thanks Eric!
>
> PS.  I'm on Ubuntu, you?
>

Michael Bahnmiller

unread,
Aug 18, 2010, 12:09:44 PM8/18/10
to sql-anywhere-w...@googlegroups.com
Eric,

I'm using SQL Anywhere 11.0.1.2044 (and the same Rails version as you).
I am also connecting remotely to a SQL Anywhere server (don't know if
that matters).
Here is what my conf/database.yml looks like (sensitive info
removed/changed):

development:
adapter: sqlanywhere

database: NameOfDB
server: server1
commlinks: tcpip(host=***.***.***.***)
connection_name: rails_test
encoding: Windows-1252
username: dba
password: sql

I also use ./script/server to start it.

The error appears in the console as soon as I try to access a page.
Here is the stack:
$ ./script/server
=> Booting Mongrel
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

Status: 500 Internal Server Error


Could not load SQLAnywhere DBCAPI library

/var/lib/gems/1.8/gems/activerecord-sqlanywhere-adapter-0.1.3/lib/active_record/connection_adapters/sqlanywhere_adapter.rb:35:in
`initialize'
/usr/lib/ruby/1.8/singleton.rb:94:in `new'
/usr/lib/ruby/1.8/singleton.rb:94:in `instance'

/var/lib/gems/1.8/gems/activerecord-sqlanywhere-adapter-0.1.3/lib/active_record/connection_adapters/sqlanywhere_adapter.rb:65:in
`sqlanywhere_connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`send'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in
`new_connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in
`checkout_new_connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in
`checkout'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`loop'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in
`checkout'
/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in
`checkout'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in
`connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in
`retrieve_connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in
`retrieve_connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in
`connection'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/query_cache.rb:9:in
`cache'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/query_cache.rb:28:in
`call'

/var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in
`call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/string_coercion.rb:25:in
`call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in
`call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in
`call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:99:in
`call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in
`call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:114:in
`call'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/reloader.rb:34:in
`run'

/var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:108:in
`call'

/var/www/rails/sybase/vendor/rails/railties/lib/rails/rack/static.rb:31:in
`call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in `call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `each'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `call'

/var/www/rails/sybase/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in
`call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in
`call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/chunked.rb:15:in `call'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:67:in
`process'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in
`process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in
`process_client'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/var/lib/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/handler/mongrel.rb:38:in
`run'
/var/www/rails/sybase/vendor/rails/railties/lib/commands/server.rb:111
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
./script/server:3

Any thoughts? Did you have to source the Env vars somehow, or did you
just install everything? Did you have to edit any other files? Or
maybe this has to do with the difference of versions?

I am running Apache2 with this just fine (but I had to source the env
vars in the apache init.d script)

Thanks!!!
Michael

Eric Farrar

unread,
Aug 18, 2010, 12:24:48 PM8/18/10
to SQL Anywhere Web Development
I didn't modify any files, but I did source the SQL Anywhere setup
script (sa_config.sh) in the shell before running script/server. Can
you give me the results of:

echo $LD_LIBRARY_PATH

Thanks,

- Eric

On Aug 18, 12:09 pm, Michael Bahnmiller
<songsofdistantea...@gmail.com> wrote:
> Eric,
>
> I'm using SQL Anywhere 11.0.1.2044 (and the same Rails version as you).
> I am also connecting remotely to a SQL Anywhere server (don't know if
> that matters).
> Here is what my conf/database.yml looks like (sensitive info
> removed/changed):
>
> development:
>    adapter: sqlanywhere
>
>    database: NameOfDB
>    server: server1
>    commlinks: tcpip(host=***.***.***.***)
>    connection_name: rails_test
>    encoding: Windows-1252
>    username: dba
>    password: sql
>
> I also use ./script/server to start it.
>
> The error appears in the console as soon as I try to access a page.  
> Here is the stack:
> $ ./script/server
> => Booting Mongrel
> => Rails 2.3.8 application starting onhttp://0.0.0.0:3000
> => Call with -d to detach
> => Ctrl-C to shutdown server
>
>    Status: 500 Internal Server Error
>    Could not load SQLAnywhere DBCAPI library
>
> /var/lib/gems/1.8/gems/activerecord-sqlanywhere-adapter-0.1.3/lib/active_re cord/connection_adapters/sqlanywhere_adapter.rb:35:in
> `initialize'
>      /usr/lib/ruby/1.8/singleton.rb:94:in `new'
>      /usr/lib/ruby/1.8/singleton.rb:94:in `instance'
>
> /var/lib/gems/1.8/gems/activerecord-sqlanywhere-adapter-0.1.3/lib/active_re cord/connection_adapters/sqlanywhere_adapter.rb:65:in
> `sqlanywhere_connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:223:in
> `send'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:223:in
> `new_connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:245:in
> `checkout_new_connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:188:in
> `checkout'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:184:in
> `loop'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:184:in
> `checkout'
>      /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:183:in
> `checkout'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:98:in
> `connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:326:in
> `retrieve_connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_specification.rb:123:in
> `retrieve_connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_specification.rb:115:in
> `connection'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/query_cac he.rb:9:in
> `cache'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/query_cac he.rb:28:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/activerecord/lib/active_record/connectio n_adapters/abstract/connection_pool.rb:361:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/string_ coercion.rb:25:in
> `call'
>      /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call'
>      /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/params_ parser.rb:15:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/session /cookie_store.rb:99:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/failsaf e.rb:26:in
> `call'
>      /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
>      /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize'
>      /var/lib/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/dispatc her.rb:114:in
> `call'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/reloade r.rb:34:in
> `run'
>
> /var/www/rails/sybase/vendor/rails/actionpack/lib/action_controller/dispatc her.rb:108:in

Michael Bahnmiller

unread,
Aug 18, 2010, 2:00:56 PM8/18/10
to sql-anywhere-w...@googlegroups.com
Hey, Eric,

Thanks to your playing around, it got me thinking, and I finally figured
out a workaround.

I'm actually not running ./script/server directly, but rather through a
vim script in order to use a debugger. Somehow the vim script wasn't
pulling the variables, soooo..... I put them directly into the vim
script (since I couldn't figure out how to source the .sh file).

Now I have it working satisfactorily.

Thanks, once again, for your help Mr Eric. :)

Michael

Reply all
Reply to author
Forward
0 new messages