8

I'm new to Ruby (coming from a Java background) and was given access to a RoR project from a Git repository. I was able to get Ruby built with rbenv and Postgres installed via homebrew, installed the "pg" gem using the correct flags. Any ways I did "bundle install" on the project and it created a bundle, when I went to start the server:... any help will be definitely appreciated!

$ rails s
/Users//Projects/The /vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in require': cannot load such file -- pg_ext (LoadError)

from /Users//Projects/The Usic/vendor/bundle/gems/pg-0.14.1/lib/pg.rb:4:in <top (required)>'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in block (2 levels) in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in each'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:70:in block in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in each'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler/runtime.rb:59:in require'

from /Users//.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.0/lib/bundler.rb:132:in require'
Mike Melusky
  • 515
  • 2
  • 7
  • 19

5 Answers5

7

Issue also appears in Fedora 17.

Uninstall "pg" gem:

gem uninstall pg

Run bundle (assuming Gemfile contains "pg" gem):

bundle
Darkside
  • 659
  • 8
  • 20
7

Add the pg gem to your Gemfile. Then run:

bundle install
bundle update
Conspicuous Compiler
  • 6,403
  • 1
  • 40
  • 52
Mukesh
  • 921
  • 10
  • 23
2

If during the installation of the gem the pq installation is not in path so it could not be found by the gem. Than the gem would not work correct.

  • Check the path (try to start psql from commandline).
  • uninstall the pg-gem: gem unistall pg
  • and reinstall it: bundle install or gem install pg
principat
  • 21
  • 1
  • I think this fixed the problem for me. I think I was running an old version of pg. Uninstalling and reinstalling gave me a newer version. Have an upvote. – Tim Dec 19 '19 at 21:52
1

I'm curious if you installed the pg gem before or after installing postgres via brew?

If pg was installed before you installed Postgres via brew, you may need to remove it and install it again so that it's compiled against your current version of Postgres.

Side note: postgresapp is a much better alternative to installing postgres via homebrew: http://postgresapp.com/

Mario Zigliotto
  • 8,315
  • 7
  • 52
  • 71
1

I've already installed the pg gem list pg

I also encountered this problem and I made it work. First, you run the command: $ gem install pg --pre
Successfully installed pg-0.21.0-x64-mingw32

Next, you update your Gemfile: gem 'pg', '~> 0.21.0'. That's it.

My rubygems environment are as follow:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.12
  - RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Ruby23-x64/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: C:/Users/armano/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: C:/Ruby23-x64/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/Ruby23-x64/bin
  - SPEC CACHE DIRECTORY: C:/Users/armano/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Ruby23-x64/lib/ruby/gems/2.3.0
     - C:/Users/armano/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
  - REMOTE SOURCES:
     - https://rubygems.org/
Arman Ortega
  • 3,003
  • 1
  • 30
  • 28