Skip to content

Developer Installation Instructions (Main)

Dave Taylor edited this page Apr 6, 2024 · 8 revisions

Developer Installation Instructions

Installation of rails basically following the standard gorails.com instructions specifically for Ubuntu 22.04

see: gorails instructions for Ubuntu 22.04 desktop

First, install various libraries needed for setup

sudo -i
apt-get update
apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
exit

Next, install asdf to manage both ruby and node versions

git clone https://github.com/excid3/asdf.git ~/.asdf
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
echo 'legacy_version_file = yes' >> ~/.asdfrc
echo 'export EDITOR="code --wait"' >> ~/.bashrc
exec $SHELL
cat ~/.asdfrc
  # it should show: legacy_version_file = yes
asdf --version
  # it should show: v0.14.0-23f4ce5

Then install the latest version of ruby (currently 3.3.0)

asdf plugin add ruby
asdf install ruby 3.3.0
asdf global ruby 3.3.0
which ruby
  # it should show: ~/.asdf/shims/ruby

Then update ruby gems

gem update --system

Then install node

asdf plugin add nodejs
asdf install nodejs 20.11.0
asdf global nodejs 20.11.0
which node
  # it should show: ~/.asdf/shims/node
node -v
  # it should show: v20.11.0

Then install node

npm install -g yarn
  # it should show: npm notice Run npm install -g [email protected] to update!

Then install npm

npm install -g [email protected]

confirm that we have git installed

git --version
  # it should show: git version 2.34.1

set up global setting for git, including the log-list alias

Note: if you prefer a different editor than vi, such as vim, use that in the instructions below

git config --global user.name "Your Name"
git config --global user.email your@email
git config --global core.editor vi
git config --global alias.log-list 'log --date=iso --graph --pretty=tformat:"%ad, %h, %s" -n 10 --date=local'
git config --global --list
  # it should show: user.name=Your Name
  #                 user.email=your@email
  #                 core.editor=vi
  #                 alias.log-list=log --date=iso --graph --pretty=tformat:"%ad, %h, %s" -n 10 --date=local

see if you already have a public/private key pair to securely communicate with github

# see of check for key pairs already existing for your user.
ls -al ~/.ssh

create a public/private key pair (to securely communicate with github), if not there already

ssh-keygen -t ed25519 -C "[email protected]"
  # it should show: Generating public/private ed25519 key pair.
  # it should show: Enter file in which to save the key (~/.ssh/id_ed25519): 

display the public key to your terminal to copy to github

cat ~/.ssh/id_ed25519.pub

go to your keys page in github to add the new key

https://github.com/settings/keys

give a title paste in the public key just listed on your terminal

attach your computer's public key to my github account

ssh -T [email protected]
  # If you see: The authenticity of host 'github.com (140.82.114.4)' can't be established.
  #             Are you sure you want to continue connecting (yes/no/[fingerprint])?
  # Then enter yes so your computer remembers the IP address you have for github
  # it should show: 
  #   Hi <yourGithubUserName>! You've successfully authenticated, but GitHub does not provide shell access.

install the version of rails needed for the project

gem install rails -v 7.1.3
rails -v
  # it should show:Rails 7.1.3

install postgresql and the dev library

sudo apt install postgresql libpq-dev

make sure the postgresql service is running and enabled

systemctl status postgresql

Create super user (name) in postgres to match my username

sudo -u postgres createuser dave -s
# You can ignore the warning: could not change directory to "/home/<ubuntuUserName>": Permission denied

confirm we can open up psql for the postgres system database as my user (with no errors)

psql postgres

set up the development database and the user who will be the owner of the database.

# Note: we are using a password of password, since the development environment is not exposed to the internet.
create database glycemic_development;
  # it should show: CREATE DATABASE
create user glycemic_development with encrypted password 'password';
  # it should show: CREATE ROLE
alter user glycemic_development CREATEDB;
  # it should show: ALTER ROLE
alter database glycemic_development owner to glycemic_development;
  # it should show: ALTER DATABASE

set up test database and the user who will be the owner of the database.

# Note: we are using a password of password, since the test environment is not exposed to the internet.
create database glycemic_test;
  # it should show: CREATE DATABASE
create user glycemic_test with encrypted password 'password';
  # it should show: CREATE ROLE
alter user glycemic_test CREATEDB;
  # it should show: ALTER ROLE
alter database glycemic_test owner to glycemic_test;
  # it should show: ALTER DATABASE

confirm databases set up properly, with the owner of the databases matches the database name (by convention):

\list

# it should show something like:
#         Name         |        Owner         
#----------------------+----------------------
# glycemic_development | glycemic_development 
# glycemic_test        | glycemic_test        
# postgres             | postgres             
# template0            | postgres             
# template1            | postgres             

Exit Postgresql psql

exit psql

exit root

\q

install ruby needed for DietSupport (originally named glycemic - TODO change this)

asdf install ruby 3.1.3
  # you should see: ==> Installed ruby-3.1.3 to ~/.asdf/installs/ruby/3.1.3

install the gems needed for DietSupport

bundle install

Bundler 2.3.26 is running, but your lockfile was generated with 2.4.3. Installing Bundler 2.4.3 and restarting using that version. ... # You should see: Bundle complete! 27 Gemfile dependencies, 102 gems now installed.

let rails create and populate databases

bin/rails db:reset
  # you should see glycemic_development and glycemic_test databases dropped and created

confirm migrations are up to date:

bin/rails db:migrate:status
  # You should see: up     20230422165418  Start over

run tests to confirm all is well

bin/rails test test
  # all tests should pass or be skipped.

rebuild app from csv files.

See: Rebuild Database

Clone this wiki locally