0

I'm trying to set up a ruby on rails project with a postgresql database and this is happening:

When I add gem 'pg' to the gemfile and run bundle install this is the output:

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

When I run gem install pg -v '0.18.4' this happens:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen

When I run sudo gem install pg -v '0.18.4' :

Building native extensions.  This could take a while...
Successfully installed pg-0.18.4
1 gem installed
Installing ri documentation for pg-0.18.4...
Installing RDoc documentation for pg-0.18.4...

When I run sudo bundle install :

An error occurred while installing mime-types-data (3.2016.0221), and Bundler cannot continue.
Make sure that `gem install mime-types-data -v '3.2016.0221'` succeeds before bundling.

When I run sudo gem install mime-types-data -v '3.2016.0221'

ERROR:  Error installing mime-types-data:
        mime-types-data requires Ruby version >= 2.0.

When I run ruby -v :

ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]

When I run sudo ruby -v :

ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux

I'm using rbenv. There are several posts about the problems I have, and I tried several things, but nothing seems to work me. Here is what I have already tried:

sudo apt-get install libpq-dev (I use Ubuntu)

a possible solution from: Error message: Make sure that `gem install pg -v '0.18.1'` succeeds before bundling

which pg_config

this will return ==> /usr/pgsql-9.1/bin/pg_config

now use this path as

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

Done now bundle install

didn't work. At this point, I'm lost. I have another ruby on rails project, which runs without problems, but every new project I start, has this problem. Any advices?

Community
  • 1
  • 1
Metaphysiker
  • 983
  • 2
  • 18
  • 35
  • try this sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3 – Mohd Anas May 20 '16 at 02:15
  • I did it and then I ran sudo bundle install and this came: An error occurred while installing byebug (9.0.4), and Bundler cannot continue. Make sure that `gem install byebug -v '9.0.4'` succeeds before bundling. When i do gem install byebug -v '9.0.4', this comes: ERROR: Error installing byebug: byebug requires Ruby version >= 2.0.0. – Metaphysiker May 20 '16 at 05:09
  • Please go through this link https://github.com/YaleSTC/shifts/issues/258 – Mohd Anas May 20 '16 at 05:34
  • I changed the gem byebug to gem 'pry-byebug', platform: [:ruby_20] and when I run sudo bundle install, it seems to work, but whenever I use bundle install, as I usually do, the same error with pg 0.18.4 comes. Do I need now to make sudo before everything I do? – Metaphysiker May 20 '16 at 06:00
  • Actually, when I use sudo bundle install, the error with pg 0.18.4 happens. – Metaphysiker May 20 '16 at 06:29
  • You don't need to do sudo bundle install. – Mohd Anas May 20 '16 at 06:48
  • If I use bundle install, this happens: An error occurred while installing pg (0.18.4), and Bundler cannot continue. Make sure that `gem install pg -v '0.18.4'` succeeds before bundling. – Metaphysiker May 20 '16 at 06:58
  • Now, the only thing you can do is uninstall PG from the system and just follow this link https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-14-04 . It should work. – Mohd Anas May 20 '16 at 07:00

1 Answers1

0

I deleted Ruby and I re-installed Ruby and it seems to work now.

Metaphysiker
  • 983
  • 2
  • 18
  • 35