Repository navigation
Development Setup
Ported from doc/DEVELOPMENT_SETUP.md in the main repo — that file is the source of truth; if the two drift, trust the repo copy and update this page to match.
This guide replaces the archived PDF Installing FreeREG on your development facility. It reflects the current stack: Rails 6.1, Mongoid/MongoDB, and optional legacy MySQL/Refinery.
| Tier | Who | Time | What you need |
|---|---|---|---|
| A — Code & PRs | Most bug fixes, controllers, services | ~1–2 hours | Ruby, MongoDB, gems, config files, test3 account |
| B — Full local FreeREG | Search, CSV upload, coordinators | ~half day | Tier A + collection imports + sample datafiles from mentor |
Most developers can work in Tier A and verify on https://test.freereg.org.uk/ without loading entire production datasets.
- Linux or WSL2 on Windows is strongly recommended.
- Native Windows is possible but more fragile (paths, MongoDB, gems).
| Component | Version / notes |
|---|---|
| Ruby |
2.7.8 (see .ruby-version). Use rbenv or rvm. |
| Bundler | Latest compatible with Ruby 2.7 |
| MongoDB | 4.4+ (local install or Docker). Server must be running for rails s. Download link: https://www.mongodb.com/try/download/community
|
| Git | Clone MyopicVicar and osgb (osgb is a Gemfile dependency). |
| MySQL | Not needed — bin/setup handles the one placeholder file the app requires. See MySQL / Refinery below. |
| Node.js | Needed for bin/setup to precompile assets (config.assets.compile is off in development here, unlike a stock Rails app — see Troubleshooting). Only likely to be missing on some Linux setups. |
- Register on https://test.freereg.org.uk/ (use the test3 syndicate).
- Ask your mentor to assign a technical role to your userid.
git clone https://github.com/FreeUKGen/MyopicVicar.git
cd MyopicVicar
# Ruby 2.7.8 (rbenv example)
rbenv install 2.7.8
rbenv local 2.7.8
# Start MongoDB first (Ubuntu example) - bin/setup only seeds the
# testuser4 test login below if MongoDB is already running
sudo systemctl start mongod
# Automated config + directories
chmod +x bin/setup bin/dev-*
bin/setup
# Edit local settings
# config/mongo_config.yml — bin/setup already fills in datafiles/website/secrets;
# only edit if you want non-default values
# config/freeukgen_application.yml — template_set: 'freereg'
# Run app
bundle exec rails s
# → http://localhost:3000 (log in as testuser4 / testuser4)bin/setup seeds a local testuser4 / testuser4 login automatically (if MongoDB is already
running when you run it). This works regardless of the random our_secret_key generated on your
machine, because the password digest is computed fresh, locally, at seed time - unlike any
UseridDetail/User records imported from a mentor's data dump, whose passwords were digested
with a different our_secret_key and won't verify here. Re-run it any time with:
bundle exec rake "dev:seed_test_login[testuser4,testuser4]"| Copy from | To | Purpose |
|---|---|---|
config/mongoid_example.yml |
config/mongoid.yml |
MongoDB database name and host |
config/mongo_config.example.yml |
config/mongo_config.yml |
datafiles path, website URL, secret keys |
config/freeukgen_application_example.yml |
config/freeukgen_application.yml |
Which app skin: freereg, freecen, freebmd
|
config/application.example.yml |
config/application.yml |
Optional Gmail env for mail tests |
config/secrets.example.yml |
config/secrets.yml |
Legacy secrets file |
config/errbit.example.yml |
config/errbit.yml |
Error reporting stub (development) |
config/database.example.yml |
config/database.yml |
Required for boot only (see MySQL / Refinery below) — placeholder values are fine |
bin/setup copies these automatically if missing and fills development secrets in mongo_config.yml.
You do not need to install MySQL. bin/setup automatically creates a placeholder
config/database.yml for you, and that's all the app needs — nothing in normal FreeREG
development actually connects to a MySQL server. (If you're curious why the file has to exist at
all when it's unused: config/application.rb loads rails/all, which pulls in
ActiveRecord::Railtie, and Rails won't boot without a config/database.yml present, even a
fake one.)
This section only matters if a mentor asks you to work on legacy Refinery CMS features (rare —
refinerycms gems are commented out in the Gemfile):
- Do not run
rake db:migrateunless told to. - To set up a real MySQL server: create MySQL DB
freereg2_development, put real credentials inconfig/database.yml, then follow legacy steps in old docs.
Obtain from your mentor / FreeUKGen Files for Development (Google Drive):
-
collections.zip— JSON dumps for core Mongo collections -
datafiles.zip— sample transcriber CSV datafiles
# Unzip collections/*.json into tmp/
bin/dev-import-collections tmp/Imports (with --drop per collection): places, churches, counties, countries, denominations, registers, syndicates, userid_details, emendation_rules, emendation_types.
Verify:
mongo
use myopic_vicar_development # or your name from config/mongoid.yml
db.places.countDocuments()Put datafiles under tmp/datafiles/testuser4/ from mentor's datafiles.zip
mkdir -p tmp/datafiles/testuser4
cp dev_setup/datafiles/*.csv tmp/datafiles/testuser4/Then process them into the database in one step:
bin/dev-load-csv-dataThis runs (in order): bin/dev-create-search-indexes (see below), freeuk:add_user (creates a
Devise User for each UseridDetail), load_emendations, build:recommence_freereg_new_update[...]
to create freereg1_csv_entries and search_records, and foo:refresh_places_cache. Add
--with-content to also rebuild freereg_contents via freereg:calculate_freereg_content —
skipped by default since it can take 30-60+ minutes. These steps are slow and hardware-dependent;
ask a mentor for a minimal county range of real data if you need more than the fixtures.
search_records queries are run with a named MongoDB index hint (e.g. county_fn_ln_rt_sd_ssd,
picked in app/models/search_record.rb). Those indexes are not created by Mongoid's normal
create_indexes — they're defined as raw createIndexes commands in
doc/design/indexes/search_records.reg (and .cen for FreeCEN), meant to be run directly against
Mongo. Without them, search fails with:
planner returned error :: caused by :: hint provided does not correspond to an existing index (2)
Run once per database:
bin/dev-create-search-indexesbin/dev-load-csv-data already calls this for you, but you can re-run it standalone at any time —
it's idempotent (createIndexes is a no-op if the index already exists with the same spec).
- By default, no real email is sent:
config/initializers/setup_mail.rbonly enables real Gmail SMTP ifgmail_username/gmail_passwordare set; otherwise mail delivery is a safe no-op (seeraise_delivery_errorsthere). - All development mail is trapped by
lib/development_mail_interceptor.rband redirected — setdev_mail_recipientinconfig/application.yml(fromapplication.example.yml) to your own address if you want to actually see trapped mail; it defaults to a non-deliverable placeholder. - To test real Gmail SMTP delivery, fill in
gmail_username/gmail_passwordinconfig/application.ymltoo. - Restart Rails after mail config changes.
config/freeukgen_application.yml:
development:
template_set: 'freereg' # or freecen, freebmdRestart rails s after changing.
| Problem | Check |
|---|---|
| Mongo connection errors |
mongod running; config/mongoid.yml host/port |
mongo_config.yml missing |
Run bin/setup
|
errbit.yml missing |
Run bin/setup or copy config/errbit.example.yml
|
App crashes on boot (rails s/rails runner/rails console) with no clear Mongo error |
config/database.yml missing — run bin/setup or copy config/database.example.yml
|
| Blank site / no places | Tier B imports not done |
| Cannot log in locally | userid on test3 + userid_details imported; not the old Refinery demo user |
filter_map / Ruby errors |
Use Ruby 2.7.8, not 2.6 |
| Pages load with no CSS/JS at all |
bin/setup runs assets:precompile for you, but this app has config.assets.compile = false in development (no on-the-fly fallback like a stock Rails app), so if it failed - often for missing Node.js - install Node.js and rerun bundle exec rake assets:precompile
|
| Search fails: "hint provided does not correspond to an existing index" | Run bin/dev-create-search-indexes
|
git checkout master
git pull
git checkout -b fr_issue_number_you_are_working_on # here fr stands for FreeREG, fc for FreeCEN, fb for FreeBMD2. eg fr_1234
# … edit …
git push -u origin fr_issue_number_you_are_working_onOpen a PR on GitHub.
| Required for all devs | Optional |
|---|---|
| Ruby 2.7.8, bundle, MongoDB, MySQL | Refinery |
Config files from examples (bin/setup handles this, including the placeholder database.yml the app needs just to boot) |
Full users.zip rebuild |
| test registration + technical role | Production-sized data |
bin/setup |
Mongo + test is enough for most developers. Full local search needs Tier B data from the team share.
© 2025 FreeUKGen. Licensed under Apache License 2.0