Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
708 views
in Technique[技术] by (71.8m points)

ruby on rails - Error message: Make sure that `gem install pg -v '0.18.1'` succeeds before bundling

i have a problem with ruby. I tried a lot but nothing works for me.

When i want to start the rails server, i get this error message:

An error occurred while installing pg (0.18.1), and Bundler cannot continue. Make sure that "gem install pg -v '0.18.1" succeeds before bundling.

This is what i tried already:

sudo install gem
bundle install
bundle install --path vendor/cache
gem install pg -v '0.18.1'

When i try gem install pg -v '0.18.1'i get this error message:

Could not find gem 'pg (>= 0) ruby' in any of the gem sources listed in your Gemfile or installed on this machine. Run bundle install to install missing gems.

But bundle installdoesn't work either. I get this error message:

An error occurred while installing pg (0.18.1), and Bundler cannot continue. Make sure that gem install pg -v '0.18.1' succeeds before bundling.

I also tried to start the server in a new ruby project.

Nothing helps..

Thanks for your help!

These are my changes in my Gemfile:

group :production do
   gem 'pg'
   gem 'rails_12factor'
 end

group :development do
   gem 'sqlite3'
 end
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you're on Ubuntu, most likely you're missing a hidden dependency

sudo apt-get install libpq-dev

If you are on OS X, try these steps

  • Install Xcode command line tools (Apple Developer site). If you have it already installed, update it using brew update.
  • brew uninstall postgresql
  • brew install postgresql
  • gem install pg

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...