aboutsummaryrefslogtreecommitdiffstats
path: root/INSTALL.md
blob: 5ed8ca9f12100cace3f713c0652134ff22cfcc08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# Installation Guide

## Ruby

Example with [rvm](https://rvm.io/) (other solutions : rbenv, packages..):

```sh
rvm install 2.3.1
```

## Node and Yarn

Yarn needs node. If you use Node Version Manager [NVM](https://github.com/creationix/nvm)  you can rely on the content of `.nvmrc`. Otherwise please make sure to use a compatible version, still best to use the same as indicated by `.nvrmc`.

* Install node

```sh
nvm install 6.12.0
```

* Install [yarn](https://yarnpkg.com/lang/en/docs/install/)

```sh
// On macOS
brew install yarn

// On Debian/ubuntu
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
```

* Install nodes packages

```sh
yarn install
```

### Installation Caveats

#### Node Related Issue, libv8

`libv8` might cause you troubles, depending on your local configuration. If you have `libv8` installed (probably because of `node.js`) you might need to tell bundler/Rubygems to use the system version.

```sh
bundle config build.libv8 --with-system-v8
bundle
```
or

```sh
gem install libv8 -v '<version>' -- --with-system-v8
bundle
```

You will get the correct value of `<version>` from bundler's error message.

#### Node Related Issue, therubyracer

Even after `libv8` installation working, the gem `therubyracer` might not like the `libv8` version chosen.

In that case however we can let the gem make its own choice:

```sh
gem uninstall libv8
gem install therubyracer -v '<version>'
```

The version to be installed is indicated in the error message bundler gave us in the first place.

This will install an appropriate `libv8` version and we can continue with `bundle`.

## Postgres

### Create user

      createuser -s -U $USER -P chouette
                  ^    ^      ^
                  |    |      +---- prompt for passwd
                  |    +----- as your default postgres user (remove in case of different config)
                  +---------- superuser

When promted for the password enter the highly secure string `chouette`.

## Rails

### Dependencies

As documented [here](https://github.com/dryade/georuby-ext/issues/2) we need some more libs before we can start the `rake` setup tasks.


On mac/OS :

```sh
brew install postgis
```

On debian/ubuntu system :

```sh
sudo apt-get install libproj-dev postgis
```

### Install gems

Add the bundler gem

```sh
gem install bundler
```

Go into your local repository and install the gems

```sh
bundle install
```

#### Nokogiri on macOS

http://www.nokogiri.org/tutorials/installing_nokogiri.html tells us that `xz` can cause troubles, here is what to do

```
brew unlink xz
gem install nokogiri # or bundle install
brew link xz
```

### Database

#### Create database

```sh
bundle exec rake db:create db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate
```

#### Load seed datas

```sh
bundle exec rake db:seed:stif
```

#### Synchronise datas with lines and stop areas referentials

* Launch Sidekiq

```sh
bundle exec sidekiq
```

* Execute the Synchronization Tasks

```sh
bundle exec rake codifligne:sync
bundle exec rake reflex:sync
```

**N.B.** These are asynchronious tasks, you can observe the launched jobs in your [Sidekiq Console](http://localhost:3000/sidekiq)

#### Data in various Apartments (Referentials)

To create `Referential` objects with some data (`Route`, `JourneyPattern`, `VehicleJourney`, etc), you need to wait codifligne and reflex jobs finished. And then you can launch :

```sh
bundle exec rake referential:create
```

### Check installation

#### Run tests

```sh
bundle exec rake spec
bundle exec rake teaspoon
```

If Postgres complains about illegal type `hstore` or `unaccent` in your tests that is probably because the shared extension is not installed, here is what to do:

      bundle exec rake db:test:purge

Thanks to `lib/tasks/extensions.rake`.



#### Start local server

```sh
bin/webpack-dev-server // Launch webpack server to compile assets on the fly
bundle exec rails server // Launch rails server
```
You need to have an account on [STIF Portail](http://stif-portail-dev.af83.priv/) to connect to the Rails application.