Installing Primero v2 for development on Ubuntu 18.04

First check out the primero source code from the repository. For example:

    mkdir ~/Dev/tmp
    cd ~/Dev/tmp
    git clone
    cd primero

We then need to get the specific branch for v2 work. To fetch a specific branch, you need to do this:

git fetch origin

This will fetch all of the remote branches for you. With the remote branches in hand, you now need to check out the branch you are interested in, giving you a local working copy:

git checkout -b development_v2 origin/development_v2

You can check your working branch now by doing

git branch

which should show you development_v2. Then move into the docker folder

cd docker

and then pull the docker images

cp local.env.sample.development local.env
sudo ./ postgres
sudo ./ solr
sudo ./ up -d postgres
sudo ./ run solr primero-test
sudo ./ up -d solr

Now that the services have started we need to install the ruby version manager

sudo apt install software-properties-common
sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt update && sudo apt-get install rvm

It is a good idea to restart your system now unless you know how to start rvm with your .bashrc file. If you do restart make sure that you start the services again that v2 needs. So that is move into the docker folder again and start the services e.g

sudo ./ up -d postgres
sudo ./ run solr primero-test
sudo ./ up -d solr

Now install the latest version of ruby

rvm install 2.6.5

and also node

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

and some binary dependencies

sudo apt-get install -y libpq-dev imagemagick libsodium-dev p7zip

Next move back into the root of the folder and install

cd ../
bundle install
npm install

and then copy the config files (review them and change anything you need)

cp config/database.yml.development config/database.yml
cp config/locales.yml.development config/locales.yml
cp config/mailers.yml.development config/mailers.yml
cp config/sunspot.yml.development config/sunspot.yml

The final step is to set some environment variables for your shell (these are 3 separate commands)

$ echo "export DEVISE_SECRET_KEY=DEVISE_SECRET_KEY" >> ~/.bashrc
$ echo "export DEVISE_JWT_SECRET_KEY=DEVISE_JWT_SECRET_KEY" >> ~/.bashrc

and then either close and reopen the bash shell or run this command in the same shell to load the environment you just set

source ~/.bashrc

Next is to create a logging directory and file so that we can log errors

mkdir log
touch log/development.log

and then prepare the database

rails db:create
rails db:migrate
rails db:seed

This last command should create all of the tables and populate them. It should output something like

Seeding Lookups
Seeding Lookup.
Updating lookup lookup-location-type
Updating lookup lookup-country
Updating lookup lookup-nationality
Updating lookup lookup-ethnicity
Updating lookup lookup-language
Updating lookup lookup-religion
Updating lookup lookup-case-status
Updating lookup lookup-conference-case-status
Updating lookup lookup-incident-status
Updating lookup lookup-displacement-status
Updating lookup lookup-unaccompanied-separated-status
Updating lookup lookup-protection-status
Updating lookup lookup-verification-status
Updating lookup lookup-risk-level
Updating lookup lookup-gbv-sexual-violence-type
Updating lookup lookup-cp-violence-type
Updating lookup lookup-armed-force-group-type
Updating lookup lookup-armed-force-group-name
Updating lookup lookup-separation-cause
Updating lookup lookup-service-type
Updating lookup lookup-followup-type
Updating lookup lookup-protection-concerns
Updating lookup lookup-unhcr-needs-codes
Updating lookup lookup-yes-no
Updating lookup lookup-yes-no-unknown
Updating lookup lookup-yes-no-undecided
Updating lookup lookup-yes-no-not-applicable
Updating lookup lookup-gbv-reported-elsewhere
Updating lookup lookup-approval-type
Updating lookup lookup-gbv-approval-types
Updating lookup lookup-approval-status
Updating lookup lookup-gender
Updating lookup lookup-inquiry-status
Updating lookup lookup-service-referred
Updating lookup lookup-workflow
Updating lookup lookup-service-implemented
Updating lookup lookup-service-response-type
Updating lookup lookup-marital-status
Updating lookup lookup-marital-status-with-spouse
Updating lookup lookup-marital-status-unknown
Updating lookup lookup-perpetrator-relationship
Updating lookup lookup-time-of-day
Updating lookup lookup-incident-location
Updating lookup lookup-incident-identification
Updating lookup lookup-disability-type
Updating lookup lookup-disability-type-with-no
Updating lookup lookup-transition-type
Updating lookup lookup-assessment-duration
Updating lookup lookup-child-minor-age-group
Updating lookup lookup-age-group-type
Updating lookup lookup-discovery-method
Updating lookup lookup-assessment-progress
Updating lookup lookup-further-action_needed
Updating lookup lookup-family-relationship
Updating lookup lookup-tracing-status
Updating lookup lookup-form-group-cp-case
Updating lookup lookup-form-group-cp-tracing-request
Updating lookup lookup-form-group-cp-incident
Updating lookup lookup-form-group-gbv-case
Updating lookup lookup-form-group-gbv-incident
Updating lookup lookup-agency-office
Seeding Export Configuration
Seeding ExportConfiguration.
Updating export configuration export-unhcr-csv
Updating export configuration export-unhcr-csv-jo
Updating export configuration export-duplicate-id-csv
Seeding the system settings
Seeding SystemSettings.
Updating System Settings
[Re-]Seeding the forms
Seeding FormSection.
Seeding Programs
Seeding PrimeroProgram.
Updating program primeroprogram-primero
Seeding Modules
Seeding PrimeroModule.
Updating module CP
Updating module GBV
Seeding Roles
Seeding Role.
Updating role role-cp-administrator
Updating role role-cp-case-worker
Updating role role-cp-manager
Updating role role-cp-user-manager
Updating role role-gbv-social-worker
Updating role role-gbv-manager
Updating role role-gbv-user-manager
Updating role role-gbv-caseworker
Updating role role-gbv-mobile-caseworker
Updating role role-gbv-case-management-supervisor
Updating role role-gbv-program-manager
Updating role role-gbv-organization-focal-point
Updating role role-agency-user-administrator
Updating role role-gbv-agency-user-administrator
Updating role role-gbv-system-administrator
Updating role role-referral
Updating role role-transfer
Updating role role-ftr-manager
Updating role role-superuser
Seeding User Groups
Seeding UserGroup.
Updating user group usergroup-primero-cp
Updating user group usergroup-primero-ftr
Updating user group usergroup-primero-gbv
Seeding Agencies
Seeding Agency.
Updating agency UNICEF
Seeding Users
Seeding User.
Updating user primero
Updating user primero_admin_cp
Updating user primero_cp
Updating user primero_mgr_cp
Updating user primero_gbv
Updating user primero_mgr_gbv
Updating user primero_ftr_manager
Updating user primero_user_mgr_cp
Updating user primero_user_mgr_gbv
Updating user agency_user_admin
Updating user primero_system_admin_gbv
Updating user agency_user_admin_gbv
Updating user primero_cp_ar
Updating user primero_mgr_cp_ar
Updating user primero_gbv_ar
Updating user primero_mgr_gbv_ar
Creating user primero_sup_gbv
Seeding Default Reports
Seeding Report.
Seeding ContactInformation.

The last thing to do is to generate the translation files

bin/rails primero:i18n_js

and then start the server.

foreman start -f

And it gave an error!

Lets dig into that and see what the issue is. Lets check our node version

ian@wintermute:~/Dev/tmp/primero$ node -v

That does not look good. Lets try with the most recent node LTS

nvm install 12.16.1

then go to http://localhost:3000/ and login with primero primer0!

You will see this

You need to make the log directory and file

After following all the steps, when I try to access the web interface I just receive a blank screen.

In the development log I found those lines at the end. Can you give me an hint on what can be the reason of that error?

This is an error as it cannot find the favicon and can be ignored. Does the front end compile?
Instead of

You can start the development Rails server on port 3000:

$ rails s

And in a separate terminal window, the development Rails Webpacker server:

$ npm run dev

then check the logs. Also why are you root? That does not look good

Same error. The front end gives a blank page.
Here the output of the development log file

I have also perform the same installation with a user who is not root and I got exactly the same result.

In general you should never be root on a linux system…just use sudo as shown in the example above.
Can you paste your .bashrc file ?

I have performed another installation with a user and I used sudo when needed (as shown in the tutorial). I got the same result.

Here my bashrc content

case $- in
    *i*) ;;
      *) return;;


shopt -s histappend


shopt -s checkwinsize

[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)

case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
unset color_prompt force_color_prompt

case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'

alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases

if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

what are your node and ruby versions ?
Are there any errors in your browsers developer tools?
is there anything in log/development.log ?

all finished fine?

are running?

Hi, I’m working with ekieyapojesus. I’ve followed these exact steps using Ruby 2.6.6, since using Ruby 2.6.5 would throw the following error when doing rails db:create:

    Ignoring executable-hooks-1.6.0 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.0
    Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
    Traceback (most recent call last):
        4: from bin/rails:3:in `<main>'
        3: from bin/rails:3:in `require_relative'
        2: from /home/martin/primero/config/boot.rb:3:in `<top (required)>'
        1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler/setup (LoadError)

On the other hand, I saw the following messages when doing npm install:

npm WARN base64-arraybuffer-es6@0.5.0 requires a peer of core-js-bundle@^3.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN chai-immutable@1.6.0 requires a peer of chai@>= 2.0.0 < 4 but none is installed. You must install peer dependencies yourself.
npm WARN connected-react-router@6.8.0 requires a peer of seamless-immutable@^7.1.3 but none is installed. You must install peer dependencies yourself.
npm WARN mui-datatables@2.14.0 requires a peer of @material-ui/core@^3.2.0 but none is installed. You must install peer dependencies yourself.
npm WARN mui-datatables@2.14.0 requires a peer of @material-ui/icons@^3.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN typeson@5.18.2 requires a peer of core-js-bundle@^3.6.4 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Installing these dependencies through npm install --save-dev does nothing.

All the other commands you mentioned are running fine. The only detail I noticed is that the rails db:* commands are showing:

warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.2-compliant syntax, but you are running 2.6.6.
warning: please see
Rspec not installed--omitting tasks

I’m using node 12.16.3, so I never saw the build error mentioned in the guide.

Maybe the ruby error on 2.6.5 is the issue?

What does gem env and echo $GEM_PATH output? Are you using Ruby Version Manager in the tutorial to handle versions and if so what version were you using to run the bundle install command?

Yes, I’m using rvm as indicated here. I tried bundle install with both versions, and it seems to work fine with 2.6.6. With 2.6.5, however, I see the following output:

Your Ruby version is 2.6.5, but your Gemfile specified 2.6.6

which is why I switched to 2.6.6. Plus, as soon as I step into the primero directory I get a message saying:

Required ruby-2.6.6 is not installed.
To install do: 'rvm install "ruby-2.6.6"'

I’ll check gem env and GEM_PATH later and update this. Thanks.

Here’s gem env for 2.6.5:

RubyGems Environment:
  - RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/martin/.rvm/gems/ruby-2.6.5
  - USER INSTALLATION DIRECTORY: /home/martin/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /usr/share/rvm/rubies/ruby-2.6.5/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /home/martin/.rvm/gems/ruby-2.6.5/bin
  - SPEC CACHE DIRECTORY: /home/martin/.gem/specs
    - ruby
    - x86_64-linux
     - /home/martin/.rvm/gems/ruby-2.6.5
     - /usr/share/rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - /home/martin/.rvm/gems/ruby-2.6.5/bin
     - /home/martin/.rvm/gems/ruby-2.6.5@global/bin
     - /usr/share/rvm/rubies/ruby-2.6.5/bin
     - /usr/share/rvm/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin

GEM_PATH is set to /home/martin/.rvm/gems/ruby-2.6.5:/home/martin/.rvm/gems/ruby-2.6.5@global.

For 2.6.6 it’s the same but with all instances of 2.6.5 replaced by 2.6.6, and RUBYGEMS VERSION replaced by 3.0.8.

I also noticed that the following appears in the output of ./ postgres:

++ docker build -f postgres/Dockerfile . -t primero/postgres:latest -t
free(): invalid pointer
SIGABRT: abort
PC=0x7f4401757e97 m=0 sigcode=18446744073709551610
signal arrived during cgo execution

After this, however, the process continues and finishes with no other errors. Something similar happens when doing ./ solr.

This may be caused as you have docker compose installed.

sudo apt-get remove docker-compose
sudo apt autoremove

Try to get 2.6.5 working.It’s possible your bundler installation is corrupt or missing so try and install it again

gem install bundler

I don’t think “getting 2.6.5 working” is the way to fix this. As soon as I try to run bundle install, I simply get an error saying that I should use 2.6.6, as that’s what Primero’s Gemfile says.

I don’t see how this could ever work with 2.6.5 without modifying the Primero sources. This seems like an error on your side.

Btw, if I remove docker-compose, the sudo ./ up -d postgres step fails:

./ 6: exec: docker-compose: not found

I just meant that this was the version working in the tutorial

Try installing docker compose from the docker site now