Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error cannot load 'pg' gem on local windows 7 Ruby on Rails

I just started to learn ruby on rails. I have pg gem installed as shown below. And 'pg' is in both gemfile.lock and gemfile. However, it keep getting error, "gem is not loaded, Add gem 'pg' to your Gemfile."

I also have tried follow someone's advice, delete the gemfile.lock and re-bundle. same error came out.

E:\RoR docs\first_app>bundle show pg
Could not find gem 'pg'.
Did you mean pg?

gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.rc2'

# Use sqlite3 as the database for Active Record
gem 'pg'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0.rc2'

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

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

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

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

# 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'

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', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

database.yml:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: postgresql
  database: first_app
  pool: 5
  username: postgres
  password: admin
  port: 5432
  timeout: 5000
  host: localhost

# 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: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

gem list:

*** LOCAL GEMS ***

actionmailer (4.0.0.rc2, 3.2.13)
actionpack (4.0.0.rc2, 3.2.13)
activemodel (4.0.0.rc2, 3.2.13)
activerecord (4.0.0.rc2, 3.2.13)
activerecord-deprecated_finders (1.0.3)
activerecord-postgresql-adapter (0.0.1)
activeresource (3.2.13)
activesupport (4.0.0.rc2, 3.2.13)
ansi (1.4.3)
arel (4.0.0, 3.0.2)
atomic (1.1.9)
bigdecimal (1.2.0)
builder (3.2.2, 3.1.4, 3.0.4)
bundler (1.3.5)
capybara (2.1.0)
coffee-rails (4.0.0, 3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.2)
diff-lcs (1.2.4)
erubis (2.7.0)
execjs (1.4.0)
formatador (0.2.4)
guard (1.8.1)
guard-rspec (3.0.2)
hike (1.2.3)
i18n (0.6.4, 0.6.1)
io-console (0.4.2)
jason (0.6.0)
jbuilder (1.4.2)
journey (1.0.4)
jquery-rails (3.0.1)
json (1.8.0, 1.7.7)
listen (1.2.2)
lumberjack (1.0.3)
mail (2.5.4)
mime-types (1.23)
mini_portile (0.5.0)
minitest (5.0.4, 4.7.4, 4.3.2)
multi_json (1.7.7)
pg (0.15.1 x64-mingw32)
pik (0.2.8)
polyglot (0.3.3)
psych (2.0.0)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (4.0.0.rc2, 3.2.13)
railties (4.0.0.rc2, 3.2.13)
rake (10.1.0, 0.9.6)
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
rb-kqueue (0.2.0)
rdiscount (2.1.6)
rdoc (4.0.1, 4.0.0, 3.12.2)
rspec (2.13.0)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.2)
sass (3.2.9)
sass-rails (4.0.0.rc2, 3.2.6)
sdoc (0.3.20)
sprockets (2.10.0, 2.2.2)
sprockets-rails (2.0.0)
test-unit (2.5.5, 2.0.0.0)
thor (0.18.1)
thread_safe (0.1.0)
tilt (1.4.1)
treetop (1.4.14)
turbolinks (1.2.0)
turn (0.9.6, 0.8.2)
tzinfo (1.0.0, 0.3.37)
uglifier (2.1.1)
xpath (2.0.0)

bundle:

E:\RoR docs\first_app>bundle
Using rake (10.1.0)
Using i18n (0.6.4)
Using minitest (4.7.4)
Using multi_json (1.7.7)
Using atomic (1.1.9)
Using thread_safe (0.1.0)
Using tzinfo (0.3.37)
Using activesupport (4.0.0.rc2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.rc2)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.14)
Using mail (2.5.4)
Using actionmailer (4.0.0.rc2)
Using activemodel (4.0.0.rc2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0.rc2)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0.rc2)
Using coffee-rails (4.0.0)
Using hike (1.2.3)
Using jbuilder (1.4.2)
Using jquery-rails (3.0.1)
Using json (1.8.0)
Using bundler (1.3.5)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0.rc2)
Using rdoc (3.12.2)
Using sass (3.2.9)
Using sass-rails (4.0.0.rc2)
Using sdoc (0.3.20)
Using turbolinks (1.2.0)
Using uglifier (2.1.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.0.0.rc2)
      actionpack (= 4.0.0.rc2)
      mail (~> 2.5.3)
    actionpack (4.0.0.rc2)
      activesupport (= 4.0.0.rc2)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.0.rc2)
      activesupport (= 4.0.0.rc2)
      builder (~> 3.1.0)
    activerecord (4.0.0.rc2)
      activemodel (= 4.0.0.rc2)
      activerecord-deprecated_finders (~> 1.0.2)
      activesupport (= 4.0.0.rc2)
      arel (~> 4.0.0)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.0.rc2)
      i18n (~> 0.6, >= 0.6.4)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.37)
    arel (4.0.0)
    atomic (1.1.9)
    builder (3.1.4)
    coffee-rails (4.0.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0.beta, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    hike (1.2.3)
    i18n (0.6.4)
    jbuilder (1.4.2)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (3.0.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.0)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.23)
    minitest (4.7.4)
    multi_json (1.7.7)
    pg (0.15.1-x86-mingw32)
    polyglot (0.3.3)
    rack (1.5.2)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.0.rc2)
      actionmailer (= 4.0.0.rc2)
      actionpack (= 4.0.0.rc2)
      activerecord (= 4.0.0.rc2)
      activesupport (= 4.0.0.rc2)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.0.rc2)
      sprockets-rails (~> 2.0.0)
    railties (4.0.0.rc2)
      actionpack (= 4.0.0.rc2)
      activesupport (= 4.0.0.rc2)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    sass (3.2.9)
    sass-rails (4.0.0.rc2)
      railties (>= 4.0.0.beta, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0)
    sdoc (0.3.20)
      json (>= 1.1.3)
      rdoc (~> 3.10)
    sprockets (2.10.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.0)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    thor (0.18.1)
    thread_safe (0.1.0)
      atomic
    tilt (1.4.1)
    treetop (1.4.14)
      polyglot
      polyglot (>= 0.3.1)
    turbolinks (1.2.0)
      coffee-rails
    tzinfo (0.3.37)
    uglifier (2.1.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  coffee-rails (~> 4.0.0)
  jbuilder (~> 1.2)
  jquery-rails
  pg (= 0.15.1)
  rails (= 4.0.0.rc2)
  sass-rails (~> 4.0.0.rc2)
  sdoc
  turbolinks
  uglifier (>= 1.3.0)

pgAdminIII is up and running: enter image description here

error page:

enter image description here

like image 633
Ivan Wang Avatar asked Jun 20 '13 18:06

Ivan Wang


Video Answer


1 Answers

Your gem list shows:

pg (0.15.1 x64-mingw32)

But your Gemfile.lock shows

PLATFORMS x86-mingw32

I think your issue is related to a mixed platform (32bits(x86) vs 64bits(x64))

Try to investigate that.

like image 153
Aguardientico Avatar answered Oct 04 '22 19:10

Aguardientico