Loomio
Tue 11 Jul 2017 1:21PM

First time setup issue

PG Prabhakar Gupta Public Seen by 52

I followed setup_environment.md and quickstart.md but I faced some problems and I am not able to troubleshoot them. I have opened #4201 as well. But still I am facing a problem in rake bootstrap step.
Please find the following logs I got after I did rake bootstrap.

Couldn't create database for {"adapter"=>"postgresql", "database"=>"loomio_test"}
rake aborted!
ActiveRecord::NoDatabaseError: FATAL:  role "prabhakar" does not exist
/home/prabhakar/Dev/loomio/app/models/motion.rb:14:in `'
/home/prabhakar/Dev/loomio/app/models/motion.rb:1:in `'
/home/prabhakar/Dev/loomio/lib/plugins/module_const_missing.rb:4:in `const_missing'
/home/prabhakar/Dev/loomio/spec/factories.rb:143:in `block in '
/home/prabhakar/Dev/loomio/spec/factories.rb:1:in `'
/home/prabhakar/Dev/loomio/config/environment.rb:5:in `'
/home/prabhakar/Dev/loomio/lib/tasks/bootstrap.rake:71:in `block in '
PG::ConnectionBad: FATAL:  role "prabhakar" does not exist
/home/prabhakar/Dev/loomio/app/models/motion.rb:14:in `'
/home/prabhakar/Dev/loomio/app/models/motion.rb:1:in `'
/home/prabhakar/Dev/loomio/lib/plugins/module_const_missing.rb:4:in `const_missing'
/home/prabhakar/Dev/loomio/spec/factories.rb:143:in `block in '
/home/prabhakar/Dev/loomio/spec/factories.rb:1:in `'
/home/prabhakar/Dev/loomio/config/environment.rb:5:in `'
/home/prabhakar/Dev/loomio/lib/tasks/bootstrap.rake:71:in `block in '
Tasks: TOP => db:setup => db:schema:load_if_ruby => environment
(See full trace by running task with --trace)
RG

Robert Guthrie Tue 11 Jul 2017 8:46PM

Hi.

Try:

rake db:setup
rake db:test:prepare

if that does not work try

createdb loomio_test
PG

Prabhakar Gupta Wed 12 Jul 2017 2:22PM

rake db:setup
rake db:test:prepare

Both were failing so i did
```
createdb loomio_test

```

  • I received an error createdb: could not connect to database template1: FATAL: role "prabhakar" does not exist which I resolved using (reference: https://stackoverflow.com/q/20692100) sudo su postgres -c 'createuser -P --superuser prabhakar' ----
  • Then, on db:setup I received ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR: could not open extension control file "/usr/share/postgresql/9.3/extension/hstore.control": No such file or directory which again I resolved by (reference : https://stackoverflow.com/q/24669862) sudo apt-get install postgresql-contrib-9.3 ----
  • Now when I do db:setup, I am receiving ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR: type "jsonb" does not exist LINE 1: ..." integer, "name" character varying, "properties" jsonb, "ti... ^ : CREATE TABLE "ahoy_events" ("id" uuid PRIMARY KEY , "visit_id" uuid, "user_id" integer, "name" character varying, "properties" jsonb, "time" timestamp) /home/prabhakar/Dev/loomio/db/schema.rb:35:in `block in <top (required)>' /home/prabhakar/Dev/loomio/db/schema.rb:14:in `<top (required)>' PG::UndefinedObject: ERROR: type "jsonb" does not exist LINE 1: ..." integer, "name" character varying, "properties" jsonb, "ti... ^ /home/prabhakar/Dev/loomio/db/schema.rb:35:in `block in <top (required)>' /home/prabhakar/Dev/loomio/db/schema.rb:14:in `<top (required)>' Tasks: TOP => db:schema:load (See full trace by running task with --trace) For which the only available solution I could find was https://stackoverflow.com/q/29393562 Could you please help me in this

(I added all the references and links in the comment so that we could add them in the quickstart.md file or some troubleshoot file after I am able to successfully setup the system. :P )

JK

James Kiesel Thu 13 Jul 2017 6:46AM

It looks to me like you have postgresql 9.3 installed, while Loomio requires 9.4 (because we use the 'jsonb' column type introduced in 9.4)

https://wiki.postgresql.org/wiki/What's_new_in_PostgreSQL_9.4

We currently support up through 9.6, so I might recommend

sudo apt-get install postgresql-9.6
or
brew install postgresql

and giving it another go.

PG

Prabhakar Gupta Thu 13 Jul 2017 3:21PM

@gdpelican @robertguthrie

Setup Successful :grin:

I had 9.3, 9.4 and 9.6 running on different ports, so I had to resolve that. After that, setup worked perfectly. (Though I had to remove the complete project and reinstall it, remove ruby environment, postgres and almost all the gems, but it worked int the end :P )

JK

James Kiesel Fri 14 Jul 2017 12:31AM

Great, glad you could get it going! Thanks for documentation PR; will review and merge shortly.

RG

Robert Guthrie Fri 14 Jul 2017 12:38AM

Yay! Congratulations. Nice work.

PG

Prabhakar Gupta Fri 14 Jul 2017 6:52AM

Yeah sure.
I will start working on the issue for which I did the complete setup.