Building Ruby on Rails - linux-on-ibm-z/docs GitHub Wiki

Building Ruby on Rails

Below versions of Ruby on Rails are available in respective distributions at the time of creation of these build instructions:

  • Ubuntu 20.04 has 5.2.3
  • Ubuntu 22.04 has 6.1.4.1
  • Ubuntu 23.10 has 6.1.7.3
  • SLES 15 SP5 has 5.2.3

The instructions provided below specify the steps to build Rails version 7.1.3.2 on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
  • SLES (12 SP5, 15 SP5)
  • Ubuntu (20.04, 22.04, 23.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Install Ruby on Rails

1.1) Install build dependencies

  • RHEL (7.8, 7.9)

    sudo yum install -y wget patch make gcc gcc-c++ npm curl libyaml-devel
    
  • Install SQLite 3.8 (Only for RHEL 7.x)

    wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
    tar zxvf sqlite-autoconf-3280000.tar.gz
    cd sqlite-autoconf-3280000
    ./configure
    make
    sudo make install
    sqlite3 --version
    
  • RHEL (8.6, 8.8, 8.9)

    sudo yum groupinstall -y 'Development Tools'
    sudo yum install -y zlib-devel zlib make gcc wget which patch gcc-c++ npm sqlite-devel curl libyaml-devel
    
  • RHEL (9.0, 9.2, 9.3)

    sudo yum install -y rpmdevtools
    sudo yum install -y zlib-devel zlib make gcc wget which patch gcc-c++ npm sqlite-devel curl ruby ruby-devel libyaml-devel
    
  • SLES 12 SP5

    sudo zypper install -y bison flex libopenssl-devel libyaml-devel libffi48-devel readline-devel zlib-devel gdbm-devel ncurses-devel tcl-devel tk-devel sqlite3-devel gcc make wget shared-mime-info tar  gcc-c++ libxslt-devel npm14 timezone curl
    
  • SLES 15 SP5

    sudo zypper install -y wget gcc zlib-devel gawk make patch tar gzip shared-mime-info sqlite-devel gcc-c++ libxslt-devel npm18 curl
    
  • Ubuntu 20.04

    sudo apt-get update
    sudo apt-get install -y wget curl patch make gcc zlib1g-dev build-essential libsqlite3-dev npm tzdata pkg-config ruby-nokogiri git libyaml-dev
    
    
  • Ubuntu (22.04, 23.10)

    sudo apt-get update
    sudo apt-get install -y wget ruby ruby-dev curl patch make gcc zlib1g-dev build-essential libsqlite3-dev npm tzdata pkg-config ruby-nokogiri git libyaml-dev
    

1.2) Build Ruby 3.2.2 (For RHEL (7.8, 7.9, 8.6, 8.8, 8.9) , SLES (12 SP5, 15 SP5) , Ubuntu (20.04) )

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Ruby/3.2.2/build_ruby.sh
bash build_ruby.sh -y

1.3) Correct the gem environment for a standard user

export GEM_HOME=$HOME/.gem/ruby
export PATH=$HOME/.gem/ruby/bin:$PATH

1.4) Enable devtoolset-7 for GCC7 (Only for RHEL 7.x)

source /opt/rh/devtoolset-7/enable

1.5) Install Ruby on Rails via gem

gem install rake                         		# For Ubuntu

gem install rails -v .2               		# For All except SLES 15.x
gem install rails -v 7.1.3.2 -- --use-system-libraries	#For SLES 15.x

1.6) Ruby on Rails is now installed. Verify version with command rails -v

  • (Output)

    Rails 7.1.3.2

Step 2: Verification

  • Install NodeJS

    cd $SOURCE_ROOT
    wget  https://nodejs.org/download/release/v16.3.0/node-v16.3.0-linux-s390x.tar.gz
    tar xzf node-v16.3.0-linux-s390x.tar.gz
    export PATH=$SOURCE_ROOT/node-v16.3.0-linux-s390x/bin:$PATH
    node -v
    
  • Install required dependencies

    gem install bundler 
    sudo npm install -g yarn
    
  • Create a new Rails application and start the web server

    mkdir myapp
    cd myapp
    echo "source 'https://rubygems.org'" > Gemfile
    echo "gem 'rails', '7.1.3.2'" >> Gemfile
    gem install racc -v '1.6.2'  #For Ubuntu 23.x only
    bundle install
    bundle exec rails new . --force --skip-bundle
    bundle install
    bin/rails server &
    

    Note: Use -b to bind Rails to the specified IP. By default, it is localhost.

  • After starting Rails server, go to http://localhost:3000

    curl http://127.0.0.1:3000
    

References: