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'
1
  • are you using ruby 2.0.0? Commented Aug 30, 2013 at 16:05

6 Answers 6

7

Issue also appears in Fedora 17.

Uninstall "pg" gem:

gem uninstall pg

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

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

1 Comment

Thanks! I'll give this a try tonight when I get home from work.
7

Add the pg gem to your Gemfile. Then run:

bundle install
bundle update

Comments

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

1 Comment

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.
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/

Comments

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/

Comments

0

I was getting the same error on my mac m1 and running this 2 commands solved the problem.

run gem uninstall pg and remove all version pg

run bundle install to install again pg

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.