Rails 3.1.0 cannot connect to sqlite database on Mac Lion

29 views
Skip to first unread message

Scott Eisenberg

unread,
May 15, 2012, 10:42:16 PM5/15/12
to rubyonra...@googlegroups.com
I'm running Rails 3.2.3 on Mac Lion with sqlite 3.7.7 and ruby 1.9.3p125.  I need to back down rails to 3.1.0 for a project but when I do that a simple index page give me a 

ActiveRecord::ConnectionNotEstablished

error.

Rails 3.2.3 works, 3.1.0 not.  Any ideas?


Just to show you it's nothing fancy....



Gem file is only:  


gem 'rails', '3.1.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platform => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

Routes:
root :to => "home#index"

home controller:  
class HomeController < ApplicationController
  def index
  end

end


Jeremy Walker

unread,
May 16, 2012, 8:22:44 AM5/16/12
to rubyonra...@googlegroups.com
On 16 May 2012 03:42, Scott Eisenberg <sco...@btrtrucks.com> wrote:
I'm running Rails 3.2.3 on Mac Lion with sqlite 3.7.7 and ruby 1.9.3p125.  I need to back down rails to 3.1.0 for a project but when I do that a simple index page give me a 

ActiveRecord::ConnectionNotEstablished

error.

What does 
bundle exec db:migrate
give you?
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Rodrigo Vieira

unread,
May 16, 2012, 10:09:17 AM5/16/12
to rubyonra...@googlegroups.com
Make sure your config/database.yml referes to proper database credentials, i.e username, password, socket.
--
Rodrigo Alves Vieira
Software Developer, Bemind


Scott Eisenberg

unread,
May 16, 2012, 12:52:34 PM5/16/12
to rubyonra...@googlegroups.com
They seem to be ok. When I take off the 3.1.0 from the rails gem in the Gemfile, it connects just fine with no other changes. 

Hassan Schroeder

unread,
May 16, 2012, 1:48:54 PM5/16/12
to rubyonra...@googlegroups.com
On Tue, May 15, 2012 at 7:42 PM, Scott Eisenberg <sco...@btrtrucks.com> wrote:
> I'm running Rails 3.2.3 on Mac Lion with sqlite 3.7.7 and ruby 1.9.3p125.  I
> need to back down rails to 3.1.0 for a project

What does "back down" mean? Are you running bundle install after
changing your Gemfile? (Personally I would blow away Gemfile.lock
first.)

Regardless, are you using rvm? If not, you should be if you're doing
work on projects using different versions of Rails.

What's the complete error trace?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

Scott Eisenberg

unread,
May 16, 2012, 9:40:01 PM5/16/12
to rubyonra...@googlegroups.com
Back down just means changing the Gemfile line from

gem 'rails', '3.2.3' change to ---->> gem 'rails', '3.1.0'

then bundle update. Nothing else.

Tried deleting Gemfile.lock. That did not help.

The reason I am doing this is I have to use a gem that won't work with 3.2.3, requires 3.1.0


I don't mess with rvm at all. It stays at:

new-host-7:jbe_debug scott$ rvm list

rvm rubies

ruby-1.9.2-p290 [ x86_64 ]
=* ruby-1.9.3-p125 [ x86_64 ]

# => - current
# =* - current && default
# * - default



The stacktrace is:

activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:409:in `retrieve_connection'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:107:in `retrieve_connection'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
activerecord (3.1.0) lib/active_record/query_cache.rb:65:in `rescue in call'
activerecord (3.1.0) lib/active_record/query_cache.rb:59:in `call'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0) lib/rails/engine.rb:455:in `call'
railties (3.1.0) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
/Users/scott/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/scott/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/scott/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'


The bundle update does:

Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2)
Using multi_json (1.3.5)
Using activesupport (3.1.0)
Using bcrypt-ruby (3.0.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0)
Using erubis (2.7.0)
Using rack (1.3.6)
Using rack-cache (1.0.3)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.4)
Using actionpack (3.1.0)
Using mime-types (1.18)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.3.3)
Using actionmailer (3.1.0)
Using arel (2.2.3)
Using tzinfo (0.3.33)
Using activerecord (3.1.0)
Using activeresource (3.1.0)
Using bundler (1.1.3)
Using coffee-script-source (1.3.3)
Using execjs (1.3.2)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.3)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.1.0)
Using coffee-rails (3.1.1)
Using jquery-rails (1.0.19)
Using rails (3.1.0)
Using sass (3.1.18)
Using sass-rails (3.1.6)
Using sqlite3 (1.3.6)
Using uglifier (1.2.4)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.

Rafael Fernández López

unread,
May 16, 2012, 10:12:01 PM5/16/12
to rubyonra...@googlegroups.com
Somewhere on your code you are forcing a establish_connection, that's the problem. At least the backtrace is exactly the same I was getting with this problem. When I investigated this issue I found out that the sqlite3 backend hasn´t got implemented the close() method, so your establish_connection will fail, because the database will be kept open.

Try to remove any establish_connection added manually, and try if it works.

I stumbled across this problem before, and I even started a thread on rails-core about this issue.

Hassan Schroeder

unread,
May 16, 2012, 11:47:51 PM5/16/12
to rubyonra...@googlegroups.com
On Wed, May 16, 2012 at 6:40 PM, Scott Eisenberg <sco...@btrtrucks.com> wrote:

> I don't mess with rvm at all.  It stays at:

Then what's the point? Use it as intended: create a new gemset just
for this 3.1 app and do a clean bundle install. Then copy in your app
and see what happens.

I just did exactly that (except I created a new test app) and it worked
out of the box (Ruby 1.9.3-p125, Rails 3.1, SQLite3, Lion).
Reply all
Reply to author
Forward
0 new messages