Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 
like image 550
phd Avatar asked May 11 '15 08:05

phd


People also ask

What is the difference between gem install and bundle install?

Almost seems like running 'gem install' adds it to the global available gems (and hence terminal can run the package's commands), whereas adding it to the gemfile and running bundle install only adds it to the application. Similar to npm install --global. that's basically it.

What is GEM installation?

gem install , in its simplest form, does something kind of like this. It grabs the gem and puts its files into a special directory on your system. You can see where gem install will install your gems if you run gem environment (look for the INSTALLATION DIRECTORY: line):


1 Answers

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
like image 139
Mihai Dinculescu Avatar answered Sep 20 '22 03:09

Mihai Dinculescu