The following text describes setting up the dev environment for Cookifed.

Cookifed uses Ruby on Rails for the backend and React for the frontend.

Requirements

  • Ruby
  • PostgreSQL 17 or higher
  • Redis
  • Node.js

Installing Ruby

Since some Linux distributions provide only older ruby environments, use rbenv to install the required ruby version. The project folder stores the required ruby version in .ruby-version.

The package rbenv provides a specific ruby environment for the project. For apt-based distributions, install it using:

sudo apt install rbenv

Otherwise see rbenv installation instructions

Additionally, install the ruby build plugin:

mkdir -p ~/.rbenv/plugins
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Prepare shell integration and install ruby:

echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
rbenv install 4.0.7

The last step also happens automatically via the bin/setup script, which reads .ruby-version by itself.

Afterwards, if you’re in the project directory, you can check your available version with ruby --version. Any other folder should give you the system’s version.

Installing ruby dependencies

The tool bundle installs all the dependencies listed in the Gemfile automatically. By default, bundle uses the system directory, where the normal user doesn’t have write access. Do not run bundle as root!

Instead, change bundle’s config to install the dependencies into a user writable directory.

bundle config set --global path '~/.local/share/gem'

Now, executing bundle install in the Cookifed directory will install all dependencies listed in the Gemfile.

If you get an error message like

Bundler::MarshalError TypeError: incompatible marshal file format (can't be read)
    format version 4.8 required; 52.48 given

you’re still using the older ruby version from the system. Please ensure the rbenv environment described above is working correctly.

Installing Redis

This is just a matter of doing

sudo apt install redis
sudo systemctl enable redis-server
sudo systemctl start redis-server

This will use the redis version available in your Linux distribution and enable it, so it’s started automatically via systemd. If you’re not using an apt based system, please use your available package manager instead.

Installing Node.js

Please follow the download instructions in case your distribution’s version is too old.

The required node.js version appears in package.json. Installing the latest LTS version should be fine.

Installing Yarn

Yarn is a package manager for JavaScript dependencies and part of the used toolchain.

Please follow the download instructions.

If Node.js is already available, install Yarn by running:

npm install -g corepack

Installing PostgreSQL

If your Linux distribution only provides PostgreSQL version 16, you need to install version 17 or higher by other means.

For Debian or Ubuntu based systems, install newer versions by adding the official PGDG repository provided by PostgreSQL, see snippet below. See also official documentation. For other distributions see: Linux downloads

sudo apt install curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt update
sudo apt install postgresql-17

Create a database user

Create a database user for Cookifed to access PostgreSQL:

sudo -u postgres psql -c "CREATE USER username WITH PASSWORD 'your_password' CREATEDB;"

Replace username and your_password accordingly.

Then create a .env file to set the environment variables for connecting to the database. Use the same username and password you used above.

cat > .env << 'EOF'
DATABASE_USER=username
DATABASE_PASSWORD=your_password
DATABASE_HOSTNAME=127.0.0.1
DATABASE_PORT=5432
EOF

If you use postgresql-18 instead of postgresql-17, you might need to change the DATABASE_PORT to 5433 instead.

Install foreman

Foreman is an app runner for Procfile-based applications. After installing, refresh the rbenv environment, otherwise you will not find foreman.

gem install foreman
rbenv rehash

Starting Cookifed

Now you can run the setup and dev scripts.

The script bin/setup calls bin/dev as part of its setup process. The setup script prepares the database, loads all the SQL structures and fills it with the initial seed files, e.g. for an admin and normal user account. It also clears old log files. The dev script sets a PORT environment variable and calls foreman to start the Cookifed application web interface.

If these scripts complete successfully, open localhost:3000 in a web browser to access Cookifed.

Find the login information for the default users in db/seeds/.