5

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

2 Answers 2

6
+50

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Good point! Thanks. Would you please tell me how to enforce bundle install x64 bits version gem? I'm a dumb newbie. x64 pg gem is already in gem list.
I think you should intall MinGW 64 bits: qt-project.org/wiki/MinGW-64-bit and then delete Gemfile.lock and then run bundle install again. But I'm not pretty sure about that.
Also you can try to install pg gem using the following command: gem install pg --platform=mswin32
I got it working after I uninstall Ruby 64 bit and installed Ruby 32 bit. Not sure why 64 bit is not working though.
Just had this exact same problem and was losing my mind, thank you for making such a thorough post and ultimately providing the answer here. I did the same thing and it worked. Thanks again.
|
0

How are you running the server? Try bundle exec rails s

7 Comments

Firstly, thank you very much for your suggestion. I have been waiting a whole day. Finally one good man replied. I have just tried bundle exec rails s. Same error page.
I don't see pg in the list of installed gems (output of bundle command that you have pasted). But I see it in the gemfile.lock. Very odd. How about "bundle install" one more time?
Thanks for advice @pedz. Yes, I tried. Still the same error page.
Maybe try adding bundler to the list of tags? This looks like a bundler question to me... I'm stumped. Sorry.
Another suggestion. do: bundle exec gem list and see if the list includes pg. I bet it does not. There is something odd about how the bundle command is doing things.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.