Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save surreymagpie/cac506c3e7d863605db322e1c1d16c29 to your computer and use it in GitHub Desktop.
Save surreymagpie/cac506c3e7d863605db322e1c1d16c29 to your computer and use it in GitHub Desktop.
Instructions for installing Ruby in Fedora Toolbox container using rbenv

Fedora doesn't ship with ruby installed and I've previously utilised rbenv to manage different versions. This gist contains instructions for using the built-in Toolbox / Podman container systems in Fedora so Ruby and Rails development can be carried out without installing packages on the base system.

This should also work well in Silverblue or similar immutable distributions.

Setting up Ruby on Rails development in a Fedora Toolbox container

On host system:

toolbox create ruby
toolbox enter ruby

Confirm ruby and rbenv are NOT installed by:

ruby -v
rbenv

should both give 'Command not found' errors.

Install prerequisites

Requirements are listed in the rbenv wiki.

sudo dnf install -y gcc rust patch make bzip2 openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel nodejs

Install rbenv and setup in bash

# Download rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash

# Setup bash
echo 'eval "$(/home/rob/.rbenv/bin/rbenv init - bash)"' >> .bashrc 
source .bashrc

# Confirm installation
wget -q "https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor" -O- | bash
type rbenv

Check ruby versions and install required version

rbenv install -l
rbenv install 3.2.1

Install Bundler and Rails

echo "gem: --no-document" > ~/.gemrc
gem install rails bundler

Installation of PostgreSQL v15.2

Inside the toolbox, systemd is not running so installing PostgreSQL using dnf will not work. However downloading from source is easy enough to do.

Download source

wget -L https://ftp.postgresql.org/pub/source/v15.2/postgresql-15.2.tar.gz
tar xzvf postgresql-15.2.tar.gz 
cd postgresql-15.2

Build

./configure
make
make all
make check
sudo make install

Initialise and run database

export PATH=/usr/local/pgsql/bin:$PATH PGDATA=/usr/local/pgsql/data
initdb
pg_ctl start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment