title: Installing Spree ActiveRecord::ConnectionNotEstablished Error
body: <p>I wanted to create an online shop using rails and the spree gem (http://spreecommerce.com/).</p>
  
  <p>Leaving rails development rest for a while on my mac (os x lion), I installed everything from the scratch using this guide: <a href="http://tecparatodos.com/2011/07/24/installing-ruby-on-rails-on-mac-os-x-lion/" rel="nofollow">http://tecparatodos.com/2011/07/24/installing-ruby-on-rails-on-mac-os-x-lion/</a> and mysql with brew.</p>
  
  <p>I also followed Spree's "Getting Started Document" <a href="http://guides.spreecommerce.com/getting_started.html" rel="nofollow">http://guides.spreecommerce.com/getting_started.html</a></p>
  
  <p>The issue that occured is that using mysql, after configuring the database and e.g. doing a </p>
  
  <pre><code>rake db:create
  </code></pre>
  
  <p>I always get the ActiveRecord::ConnectionNotEstablished error. First I thought it has to do with my mysql installation but after hours of checking and reinstalling I figured out that it actually was because of the spree gem. Whenever I add "gem 'spree'" to my Gemfile, this error occures. When I remove it and do a "bundle install", everything works fine. I have some rails experience on a view projects but spree is new to me. Any idea what could be the issue?</p>
  
  <p>My database.yml:</p>
  
  <pre><code>development:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: asiashop_development
    pool: 5
    username: root
    password:
    socket: /tmp/mysql.sock
  
  # Warning: The database defined as "test" will be erased and
  # re-generated from your development database when you run "rake".
  # Do not set this db to the same as development or production.
  test:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: asiashop_test
    pool: 5
    username: root
    password:
    socket: /tmp/mysql.sock
  
  production:
    adapter: mysql2
    encoding: utf8
    reconnect: false
    database: asiashop_production
    pool: 5
    username: root
    password:
    socket: /tmp/mysql.sock
  </code></pre>
  
  <p>And the stracktrace when I do "rails c":</p>
  
  <pre><code>/Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/model_schema.rb:224:in `columns'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.0.rc2/lib/active_record/model_schema.rb:244:in `column_names'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:61:in `ordering_condition_details'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/rd_searchlogic-3.0.1/lib/searchlogic/named_scopes/ordering.rb:52:in `method_missing'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:105:in `&lt;class:Base&gt;'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core/find_by_param.rb:104:in `&lt;top (required)&gt;'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `block in require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:236:in `load_dependency'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0.rc2/lib/active_support/dependencies.rb:251:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree_core-0.40.0/lib/spree_core.rb:47:in `&lt;top (required)&gt;'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/spree-0.40.0/lib/spree.rb:1:in `&lt;top (required)&gt;'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
      from /Users/mark/Documents/Workspace/Asia Testshop/asiashop/config/application.rb:7:in `&lt;top (required)&gt;'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:39:in `require'
      from /Users/mark/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:39:in `&lt;top (required)&gt;'
      from script/rails:6:in `require'
      from script/rails:6:in `&lt;main&gt;'
  </code></pre>
  
  <p>As I wrote, it can not be a general mysql conenction problem because everything works fine as long as I do not use the spree gem.</p>