0

I am trying to resolve this error but am unsuccessful and looked through some of the previous SO threads on this issue.

'sudo apt-get install libpq-dev postgresql-devel' did not work as I dont have apt-get. I tried replacing apt-get with wget and that did not work either.

I also tried the following but that did not work either and I got the error below

export PATH=/usr/pgsql-9.3/bin:$PATH bundle install

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

Can anyone advise? I am on a Mac OSx V9.10.5

sgx
  • 1,265
  • 3
  • 19
  • 36

3 Answers3

1

First you need install postgresql:

brew install postgresql

If you still get errors for missing paths, then check this question.

Community
  • 1
  • 1
mohameddiaa27
  • 3,587
  • 1
  • 16
  • 23
  • Ok I have definitely done this step and it seemed to be successful. I got this message so I"m assuming I had success: Warning: postgresql-9.3.5_1 already installed – sgx Oct 30 '14 at 18:15
  • This error occurs when I try to run rails server: /Users/user/.rvm/gems/ruby-2.1.2@blablabla/gems/railties-4.1.1/lib/rails/application/configuration.rb:105:in `database_configuration': Cannot load `Rails.application.database_configuration`: (RuntimeError) – sgx Oct 30 '14 at 18:18
  • did you start the postgresql server `postgres -D /usr/local/var/postgres` ? – mohameddiaa27 Oct 30 '14 at 18:21
  • You mean just run that before rails server? I typed in your command and got this: LOG: database system was shut down at 2014-10-30 13:21:40 EDT LOG: autovacuum launcher started LOG: database system is ready to accept connections I then opened a new terminal tab and got the same error for 'rails server' – sgx Oct 30 '14 at 18:23
0

apt-get is package manager for linux, not for mac. Use homebrew for MacOS. Instructions here http://brew.sh/

Pavel Tkackenko
  • 963
  • 7
  • 20
  • I have homebrew installed. I tried 'brew install pg' and 'brew install pgsql' Neither worked. – sgx Oct 30 '14 at 17:16
  • Try to completely remove postgres, and reinstall, as one one wise man shows in link, which I provided. – Pavel Tkackenko Oct 30 '14 at 17:24
  • I ran bundle install and it shows pg 0.17.1 is included, and then I also see PostgreSQL is installed. However, 'rails server' is still leading to errors. – sgx Oct 30 '14 at 18:31
0

An alternative solution: Download the postgresql.app:

Create or modify the config/database.yml file, adding the following configuration:

development:
  adapter: postgresql
  encoding: unicode
  database: name_of_app_development
  pool: 5
mohameddiaa27
  • 3,587
  • 1
  • 16
  • 23
  • So I did that and now have a postgreSQL server running. But 'rails server' is still producing the same errors – sgx Oct 30 '14 at 18:41
  • Do you have the correct configuration in your `database.yml` file ? – mohameddiaa27 Oct 30 '14 at 18:46
  • Hmm..I don't think so. That seems to be my error, how do I fix this? – sgx Oct 30 '14 at 18:47
  • /Users/user/.rvm/gems/ruby-2.1.2@blablabla/gems/railties-4.1.1/lib/rails/application/configuration.rb:105:in `database_configuration': Cannot load `Rails.application.database_configuration`: (RuntimeError) Could not load database configuration. No such file - /Users/user/Desktop/blablabla/config/database.yml – sgx Oct 30 '14 at 18:48
  • Hmm...I don't seem to have one. In my .gitignore file I have something that looks like this: # bundler state /.bundle /vendor/bundle/ /vendor/ruby/ # minimal Rails specific artifacts db/*.sqlite3 /db/*.sqlite3-journal /log/* /tmp/* # various artifacts **.war *.rbc *.sassc .redcar/ .sass-cache /config/config.yml /config/database.yml /coverage.data /coverage/ /db/*.javadb/ /db/*.sqlite3 /doc/api/ /doc/app/ etc etc... – sgx Oct 30 '14 at 18:54
  • I did not create this project, I am trying to work on it however. The above is the only mention of database.yml in my entire project – sgx Oct 30 '14 at 18:54
  • Ok, so that definitely seemed to get the rails server working. In terms of my project I am still having issues with it. I got prompted with an issue saying run 'bin/rake db:create' and then another issue that said run 'bin/rake db:migrate RAILS_ENV=development' Currently I have the following error. undefined local variable or method `root_path' for # – sgx Oct 30 '14 at 19:05
  • Can you help explain what the issues are. I think you were definitely correct with creating a database.yml file, but now there seem to be completely different issues and for the most part the project should be working correctly – sgx Oct 30 '14 at 19:06
  • 1
    Actually this solved both your postgresql installation, and its configuration. You can run `rails c` to make sure the database is working fine. The new issue you got is different, please create a new question for that – mohameddiaa27 Oct 30 '14 at 19:08
  • What is in the file you posted? In particular: database: name_of_app_development pool: 5 – sgx Oct 30 '14 at 19:10
  • 1
    This file includes the database configuration for all environments, I've posted only the development configuration, "database" is the name of your database (usually set as the name_of_the_app underscore environment. read more at about [Configuring a PostgreSQL Database](http://guides.rubyonrails.org/configuring.html#configuring-a-postgresql-database) – mohameddiaa27 Oct 30 '14 at 19:14
  • So do I need to change the name_of_app_development to be the name of my project? – sgx Oct 30 '14 at 19:23
  • yes, exactly. But this is local only on your device, so you can leave it as is. – mohameddiaa27 Oct 30 '14 at 19:27
  • Ok thanks for all of your help. I am starting another thread for the next question: http://stackoverflow.com/questions/26661659/undefined-local-variable-or-method-root-path-for-registrationscontroller0x0 – sgx Oct 30 '14 at 19:28