Can't precompile assets, some authentication problem


(Germansokolov13) #1

I am trying to run

bundle exec rake assets:precompile RAILS_ENV=production

And have this output:

rake aborted!
PG::Error: FATAL:  Peer authentication failed for user "discourse"

After that goes a stack trace.

What can I do wrong? Or at least, what is this “discourse” user, where are it’s credentials and how those are used in the precompile?

I am running it on Ubuntu 13.10, with rvm instead of rbenv without vagrant. Running rails s seems to work fine, specs show several fails considering something about absolute urls and avatars. I used rails console to make my accaunt admin.


(Justin Bowes) #2

Looks like Rails is failing to connect to your PostgreSQL instance. Check your database config.


(Jonathan Feist) #3

if you have the programme locate, then try locate pg_hba.conf and open up and edit that file. Probably something like sudo nano /etc/postgresql/9.3/main/pg_hba.conf and edit the line for local all all peer and change peer to md5. You then want to make sure your discourse user had a password set up, if you were following a tutorial, it probably is. Restart postgres with a command something like sudo /etc/init.d/postgresql restart


(Germansokolov13) #5

OK, now I get it. So the PostgreSQL user must be called exactly “discourse” and nothing else? Where is this name configured? I didn’t expect it because I thought this user name is set in database.yml. I have rechecked all that and now when doing precompile I get this error:

rake aborted!
PG::Error: fe_sendauth: no password supplied

I made “discourse” as “discourse”'s password in PostgreSQL. Where else do I need to supply it?


(Jonathan Feist) #6

ALTER ROLE discourse WITH ENCRYPTED PASSWORD 'discourse' LOGIN CREATEDB SUPERUSER;

In the database.yml enter in password: discourse under username: discourse, indented with spaces, not tabs.

  username: discourse
  password: discourse

(Germansokolov13) #7

I’ve done it and no difference, the same “no password supplied” error message

I’ve changed pg_hba.conf into this:

local   all         all                               trust
host    all         all         127.0.0.1/32          trust
host    all         all         ::1/128               trust

And now I see error message stating there is no database named “disourse”. But my databases were called “discourse_development” and “discourse_test”. I runed

bundle exec rake db:create RAILS_ENV=production

And then

bundle exec rake db:migrate RAILS_ENV=production

And fail both migration and precompiling with the same error message:

rake aborted!
No address associated with hostname

Precompiling assets requires me to use RAILS_ENV=production and there r no setting about production database in database.yml, this confuses me completely, I don’t know what is going on.


(Germansokolov13) #8

Do I actually need a 3rd database for production environment to run assets:precompile? If yes, how do I set it up? With what name, user and password?


(Sam Saffron) #9

no, you don’t need a third db, all you need is working redis and a working db.


(Germansokolov13) #10

Then why does it say about database “discourse”, when it’s set to connect to “discourse_development” and “discourse_test”?


(Sam Saffron) #11

I don’t understand what you are trying to do, are you trying to develop locally or make a production deployment?


(Germansokolov13) #12

I thought I need to precompile assets localy before I can push to production. I am trying to deploy on Heroku.


(Jonathan Feist) #13

Try manually creating a database called discourse (which will be for the discourse postgresql user) as the postgres user and try again.