This guide will walk you through setting up the neccessary environment using WSL (Windows Subsystem for Linux), which will allow you to run Ubuntu on your Windows machine.
You will need the following local tools installed:
- WSL
- Ruby
- NodeJs (optional)
- Postgres
- Google Chrome
-
Install WSL.
wsl --install
The above command only works if WSL is not installed at all, if you run
wsl --install
and see the WSL help text, do--install -d Ubuntu
-
Run Ubuntu on Windows
You can run Ubuntu on Windows several different ways, but we suggest using Windows Terminal.
To open an Ubuntu tab in Terminal, click the downward arrow and choose 'Ubuntu'.
The following commands should all be run in an Ubuntu window.
Install a ruby version manager like rbenv
Be sure to install the ruby version in .ruby-version
. Right now that's Ruby 3.1.0.
Instructions for rbenv:
-
Install rbenv
sudo apt install rbenv
-
Set up rbenv in your shell
rbenv init
-
Close your Terminal window and open a new one so your changes take effect.
-
Verify that rbenv is properly set up
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
-
Be sure to install the ruby version in
.ruby-version
. Right now that's Ruby 3.1.0.rbenv install 3.1.0
-
Set a Ruby version to finish installation and start
rbenv global 3.1.0
ORrbenv local 3.1.0
The Casa package frontend leverages several javascript packages managed through yarn
, so if you are working on those elements you will want to have node, npm, and yarn installed.
-
(Recommended) Install nvm
NVM is a node version manager.
-
Expand 'Alternatives' and select 'Debian/Ubuntu' for detailed instructions.
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 update
sudo apt install yarn
-
Install PostgresSQL for WSL
sudo apt install postgresql postgresql-contrib
- installpsql --version
- confirm installation and see version number -
Install libpq-dev library
sudo apt-get install libpq-dev
-
Start your postgresql service
sudo service postgresql start
Many of the frontend tests are run using Google Chrome, so if you don't already have that installed you may wish to install it.
Casa's install will also install the correct version of Rails.
-
Download the project
You should create a fork in GitHub if you don't have permission to directly commit to this repo. See our contributing guide for more detailed instructions.
git clone <git address>
- use your fork's address if you have oneie
git clone https://github.com/rubyforgood/casa.git
-
Installing Packages
cd casa/
bundle install
- install ruby dependencies.yarn
- install javascript dependencies. -
Database Setup
Be sure your postgres service is running (
sudo service postgresql start
).Create a postgres user that matches your Ubuntu user:
sudo -u postgres createuser <username>
- create usersudo -u postgres psql
- logs in as the postgres userpsql=# alter user <username> with encrypted password '<password>';
- add passwordpsql=# alter user <username> CREATEDB;
- give permission to your user to create databasesSet up the Casa DB
bin/rails db:setup
- sets up the dbbin/rails db:seed:replant
- generates test data (can be rerun to regenerate test data) -
Webpacker One Time Setup
bundle exec rails webpacker:compile
See Running the App / Verifying Installation.
A good option for editing files in WSL is Visual Studio Code Remote- WSL