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?