-
Notifications
You must be signed in to change notification settings - Fork 1
Windows Environment Configuration
- Install Ubuntu in the Windows Subsystem for Linux (WSL).
- Install Ubuntu from the Microsoft Store.
- The latest version of the “main” Ubuntu store listing should be 22.04. If it isn’t, then use the dedicated 22.04 LTS store listing.
- Open the newly installed Ubuntu app.
- Complete the guided Ubuntu set-up process.
- Install Ubuntu from the Microsoft Store.
- Download and unpack Swift.
- Go to the Swift download page.
- Copy the download link for Swift 5.9.2 (or whatever the latest version is) for Ubuntu 22.04 on your processor architecture (either “x86_64” or “aarch64”).
- Open an Ubuntu terminal as root.
- Run
apt-get install binutils gh git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev libpython2.7 libsqlite3-dev libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config postgresql tzdata uuid-dev wget zlib1g-dev
. - Run
cd ~/
. - Run
wget [swift-link]
, where[swift-link]
is the link that you copied in step 2.ii. - Run
tar -xvzf [swift-archive]
, where[swift-archive]
is the path to the archive file that you dowloaded in step 2.vi. - Run
rm [swift-archive]
to remove the downloaded archive file. - Run
mv [swift-directory] swift
, where[swift-directory]
is the Swift directory that was created in step 2.vii.-
[swift-directory]
should be the same as[swift-archive]
, minus the.tar.gz
suffix.
-
- Run
echo 'export PATH="$PATH":/root/swift/usr/bin' >> ~/.bashrc
. - Close the Ubuntu terminal.
- Set up PostgreSQL.
- Open an Ubuntu terminal as root.
- Run
service postgresql start
. - Run
su postgres
. - Run
psql
. - Run
CREATE DATABASE shuttle_tracker;
.- Make sure to include the semicolon!
- Run
ALTER USER postgres PASSWORD '[sql-password]';
, where[sql-password]
is a new password of your choice.- Make sure to include the semicolon!
-
[sql-password]
doesn’t have to be secure because your local PostgreSQL server won’t be accessible over the Internet. However, the password will be stored in plain text, so don’t reuse a different password that does need to remain secure.
- Type
\q
and press Return. - Close the Ubuntu terminal.
- Install and configure Visual Studio Code.
- Install Visual Studio Code from the Microsoft Store.
- Open Visual Studio Code.
- Select the “Extensions” sidebar.
- The sidebar picker should be on the left side of the window.
- Search for “Swift”.
- Install the extension in the search results that’s named “Swift” and that’s published by “Swift Server Work Group”.
- Make sure to install the right extension; other extensions might not offer the features that you’ll need to work on Shuttle Tracker Server.
- Search for “Remote - WSL”.
- Install the extension in the search results that’s named “Remote - WSL” and that’s published by “Microsoft”.
- Close Visual Studio Code.
- Clone the Shuttle Tracker Server repository.
- Open an Ubuntu terminal as root.
- Run
cd /home/[ubuntu-username]/
, where[ubuntu-username]
is your Ubuntu username.- You can use a different path if you prefer to keep your local Shuttle Tracker working copy elsewhere.
- Run
gh auth login
and follow the prompts to sign in to your GitHub account.- It’s recommended that you select the HTTPS protocol because some tools don’t work well with Git authentication over SSH.
- Make sure to respond with
Y
to the prompt that asks if you want to authenticate Git with your GitHub credentials. - You’ll probably find it easiest to authenticate with a Web browser instead of a token when you’re prompted to choose between those two options.
- Run
gh repo clone wtg/Shuttle-Tracker-Server
. - Close the Ubuntu terminal.
- Build and run the server.
- Open Visual Studio Code.
- In the bottom-left corner of the window, click the green button with two opposing arrowheads.
- Select “Open Folder in WSL…”.
- Navigate to and select your local Shuttle Tracker Server folder.
- If prompted, select “Yes, I trust the authors”.
- Select the “Extensions” sidebar.
- The sidebar picker should be on the left side of the window.
- Click “Install in WSL: Ubuntu” for “Swift”.
- This should automatically install both “Swift” and “CodeLLDB” in WSL.
- If prompted, select “Global”.
- Click the gear icon for “Swift” and select “Extension Settings” from the drop-down menu.
- Set the “Swift: Path” setting to “/root/swift/usr/bin”.
- Press Ctrl-Shift-P.
- Type “Reload Window” and press Return.
- In the “Run” menu, select “Open Configurations”
- If the “Open Configurations” menu item is disabled, then select “Add Configuration…” instead. Select “LLDB” in the prompt that follows.
- In the
launch.json
file that’s opened, add the following JSON snippet to all existing configurations:"env": { "POSTGRES_HOSTNAME": "localhost", "POSTGRES_USERNAME": "postgres", "POSTGRES_PASSWORD": "[sql-password]" }
- Replace all instances of
<executable file>
with.build/debug/Server
- In the “Run” menu, select “Start Debugging”.
- The first build might take a while. Future builds should be much faster.
- If the first build fails, then try again. Sometimes, the build system unexpectedly exits too early.
- If a connection failure is reported in the console, then open a new Ubuntu terminal as root and run
service postgresql start
.
Currently, the server is configured to use the default PostgreSQL database, not the shuttle_tracker
database that you created while following the above instructions. This could cause issues in the future if we change the database schema, so you might want to edit configure.swift
to refer to the custom database. Don’t commit the change, though.
If, while following the steps above, you run into either the CREATE DATABASE shuttle_tracker;
command hanging or tar -xvzf [swift-archive]
returning error messages, then you might need to update WSL to version 2. (This solution only works for Windows users.)
- Enable Windows Features.
- Open “Turn windows features on or off” by searching for it in the Start menu.
- Enable the following features:
- “Virtual Machine Platform”
- “Windows Hypervisor Platform/Hyper V”
- “Windows Subsystem for Linux”
- Select “OK” and restart your computer.
- Upgrade from WSL 1 to WSL 2.
- Download and install the WSL kernel update.
- Open the Windows Command Prompt as administrator.
- Run
wsl -l -v
.- This will show you a list of installed Linux distributions.
- Run
wsl --set-version [distribution] 2
, where[distribution]
is the distribution listed in step 2.iii that you want to update. - Run
wsl -l -v
again to verify that the WSL version has been updated.
This section is optional. It will install pgAdmin, a GUI tool for managing PostgreSQL servers. You will still need to use WSL to start the local PostgreSQL server.
- Download pgAdmin.
- Go to the pgAdmin download page.
- Select the relevant distribution (Windows).
- Select the newest version to download it.
- If it takes you to another page, then select
pgadmin4-….exe
to download.
- If it takes you to another page, then select
- Run the installer and follow the directions, selecting default options if you’re unsure.
- Set up pgAdmin.
- Open Ubuntu and run
service postgresql start
as root. - Open pgAdmin
- If it’s your first time opening pgAdmin, then it will ask that you set a master password to protect your server passwords.
- Create the new server and give it an appropriate name.
- Go to the connection tab and put
localhost
as the hostname/address, making sure thatpostgres
is the username and that the password is set to the password that you chose when first setting up environment (“[sql-password]”). - Save the server.
- If you haven’t already created the database using
CREATE DATABASE shuttle_tracker;
, then you can do the same here.- Right-click “Databases” under your server.
- Select “Create” and then “Database…”.
- Name it
shuttle_tracker
. - Select “Save”.
- Open Ubuntu and run