rails wants to use PG but mysql is specified

mgreschke

had a working rails app and get a weird bug - rails wants to use postgresql even tho mysql adapter is specified. Everything worked 100% fine til I worked on another project that uses postgresql.

But still, this doesn't make ANY sense. I've been on this for hours. Maybe I'm just blind, I'd appreciate the help big times.

error msg for local testing:

bash-3.2$ rails s
=> Booting WEBrick
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile. (Gem::LoadError)
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/connection_specification.rb:32:in `spec'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_handling.rb:39:in `establish_connection'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/railtie.rb:176:in `block (2 levels) in <class:Railtie>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `each'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/railtie.rb:174:in `block in <class:Railtie>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:30:in `run'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/mg/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/application.rb:215:in `initialize!'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/mg/Dropbox/delightotet/delighto/config/environment.rb:16:in `<top (required)>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/polyglot-0.3.4/lib/polyglot.rb:65:in `require'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `block in require'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.3/lib/active_support/dependencies.rb:229:in `require'
    from /Users/mg/Dropbox/delightotet/delighto/config.ru:3:in `block in <main>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/mg/Dropbox/delightotet/delighto/config.ru:in `new'
    from /Users/mg/Dropbox/delightotet/delighto/config.ru:in `<main>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands/server.rb:48:in `app'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands/server.rb:75:in `start'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:71:in `tap'
    from /Users/mg/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.3/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

database.yml

development:
  adapter: mysql2
  database: xxx
  user: xxx 
  password:

# 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
  database: xxx
  user: xxx 
  password:

production:
  adapter: mysql2
  database: xxx
  user: xxx 
  password: xxx

My Gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.3'
gem 'mysql2'

gem 'sprockets', '2.11.0'
gem 'mail_form'

# Use SCSS for stylesheets
gem 'sass-rails'

# DROPBOX
gem 'dropbox-sdk'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails'

#mailchimp
gem 'gibbon'
gem 'mandrill-api'

gem 'net-ssh', '~>2.7.0'

#devise auth 
gem 'devise'

# SUPPORT PROCESSES
gem "zendesk_api"

# AFTER SALES PROCESSES

# SHIPPING SOLUTIONS
gem 'dhl-intraship'

# GENERATE PDF INVOICE
gem 'spree_print_invoice' , :git => 'https://github.com/mgreschke/spree_print_invoice.git', branch:'2-2-stable'


# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'gritter'
gem 'friendly_id'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

#password encryption
gem "bcrypt-ruby", :require => "bcrypt"
gem 'money', '6.0.1'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
gem "capistrano", "2.14.2",  group: :development
gem "mime-types", "1.25"
gem "rake", "10.3.1"

#meta tags
gem 'meta-tags'
# Use debugger
# gem 'debugger', group: [:development, :test]
gem 'spree', '2.2.1'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-2-stable'
gem 'spree_i18n', :github => 'spree/spree_i18n', :branch => '2-2-stable'
Frederick Cheung

If you have an environment variable called DATABASE_URL then rails will use that.

This is documented in the rails guides and it particular states that rails will try to merge database.yml with the environment variable with the environment variable taking precedence.

I think that as part of one of these other postgres projects you mentioned you have set this environment variable. If you run env at your shell prompt then you should see a list of environment variables. If DATABASE_URL is there and persists after you open/close a terminal window then you are probably setting it in one of your shell startup files (for example for bash try .bashrc, .bash_profile)

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

a package wants me to use a system mail name

분류에서Dev

PG : ConnectBad Rails 4 Postgresql

분류에서Dev

Rails groupdate gem pg error

분류에서Dev

Rails Upsert PG created_at 문제

분류에서Dev

Rails Ransack 검색 PG hstore

분류에서Dev

Rails PG :: SyntaxError : ERROR 설명

분류에서Dev

Rails + Big Sur + pg 및 Spring 충돌?

분류에서Dev

Heroku에서 gem 'pg'설치 문제-Rails

분류에서Dev

Ruby on Rails: Bad connection with PG after running rake:db migrate

분류에서Dev

pg_search를 사용한 Typeahead Bloodhound Rails

분류에서Dev

PG :: UndefinedTable 오류 루비 on rails heroku

분류에서Dev

use regular expression to prase specified protocol

분류에서Dev

use regular expression to prase specified protocol

분류에서Dev

Rails / MySQL ActiveRecord :: RecordNotUnique

분류에서Dev

Rails how to use console

분류에서Dev

Use external configuration in Rails

분류에서Dev

Rails PG :: ForeignKeyViolation : ERROR : 테이블에 삽입 또는 업데이트

분류에서Dev

Rails Migration-PG :: Error : ERROR : 잘못된 정수 입력 구문 : ""

분류에서Dev

Rails 4.2 + PG-ActiveRecord 객체를 초기화 할 수 없음

분류에서Dev

Rails 4.2 + PG-ActiveRecord 객체를 초기화 할 수 없음

분류에서Dev

Rails : Pg 검색, associated_against 기능으로 dmetaphone 구현

분류에서Dev

Ruby on Rails : rake : db migrate 실행 후 PG와의 연결 불량

분류에서Dev

Rails PG GroupingError 열은 GROUP BY 절에 나타나야합니다.

분류에서Dev

Rails PG GroupingError 열은 GROUP BY 절에 나타나야합니다.

분류에서Dev

capistrano, rails, PG :: ConnectionBad : fe_sendauth : 제공된 비밀번호 없음

분류에서Dev

Rails / Postgres : pg gem 버전 변경 후 오류

분류에서Dev

MySQL Query returning all dates instead of specified year and month clauses

분류에서Dev

How to use postgres with rails on heroku

분류에서Dev

pandas series use truncate get specified hours, minutes and seconds?

Related 관련 기사

  1. 1

    a package wants me to use a system mail name

  2. 2

    PG : ConnectBad Rails 4 Postgresql

  3. 3

    Rails groupdate gem pg error

  4. 4

    Rails Upsert PG created_at 문제

  5. 5

    Rails Ransack 검색 PG hstore

  6. 6

    Rails PG :: SyntaxError : ERROR 설명

  7. 7

    Rails + Big Sur + pg 및 Spring 충돌?

  8. 8

    Heroku에서 gem 'pg'설치 문제-Rails

  9. 9

    Ruby on Rails: Bad connection with PG after running rake:db migrate

  10. 10

    pg_search를 사용한 Typeahead Bloodhound Rails

  11. 11

    PG :: UndefinedTable 오류 루비 on rails heroku

  12. 12

    use regular expression to prase specified protocol

  13. 13

    use regular expression to prase specified protocol

  14. 14

    Rails / MySQL ActiveRecord :: RecordNotUnique

  15. 15

    Rails how to use console

  16. 16

    Use external configuration in Rails

  17. 17

    Rails PG :: ForeignKeyViolation : ERROR : 테이블에 삽입 또는 업데이트

  18. 18

    Rails Migration-PG :: Error : ERROR : 잘못된 정수 입력 구문 : ""

  19. 19

    Rails 4.2 + PG-ActiveRecord 객체를 초기화 할 수 없음

  20. 20

    Rails 4.2 + PG-ActiveRecord 객체를 초기화 할 수 없음

  21. 21

    Rails : Pg 검색, associated_against 기능으로 dmetaphone 구현

  22. 22

    Ruby on Rails : rake : db migrate 실행 후 PG와의 연결 불량

  23. 23

    Rails PG GroupingError 열은 GROUP BY 절에 나타나야합니다.

  24. 24

    Rails PG GroupingError 열은 GROUP BY 절에 나타나야합니다.

  25. 25

    capistrano, rails, PG :: ConnectionBad : fe_sendauth : 제공된 비밀번호 없음

  26. 26

    Rails / Postgres : pg gem 버전 변경 후 오류

  27. 27

    MySQL Query returning all dates instead of specified year and month clauses

  28. 28

    How to use postgres with rails on heroku

  29. 29

    pandas series use truncate get specified hours, minutes and seconds?

뜨겁다태그

보관