Automating PowerRuby installation
Tags: ruby, powerruby, ibmi
Published: 2019-03-05 17:43:46

---
title: Automating PowerRuby installation
published: true
description: Want to automate PowerRuby CE2 installation on your IBM i?
tags: ruby, powerruby, ibmi
---

I've been working with a client who has been using an older version of PowerRuby and has recently wanted to upgrade to PR CE2 (Community Edition 2.0).

For those that don't know what PowerRuby is, it's Ruby and Ruby on Rails built for the IBM i operating system. They compile Ruby and some gems specifically for use on IBM i.

* You can see the [PowerRuby website here](https://powerruby.com/)
* You can see PowerRuby guides and binaries on their [GitHub page here](https://github.com/PowerRuby)

The [first guide on the org](https://github.com/PowerRuby/DE_train_01) explains that you need to download the save files and run the `RSTLICPGM` (restore licensed program) command manually - ew! In 2018, [we got yum](https://worksofbarry.github.io/rpg-git-book/3-tooling) on IBM i to install packages like the Ruby runtime (Node.js, python, etc) automatically with the `yum` command. PowerRuby has not adopted this method which is very sad.

Of course, for this to work you will need `make` and `curl` which is available from the default IBM yum repository:

```
yum install curl.ppc64 make-gnu.ppc64
```

I wanted an easy way to get PowerRuby running on IBM i, so I went ahead and created a makefile to run all the commands required to install the PR licensed program from the web. This process will create the save files, download the contents and restore the programs with `RSTLICPGM`:

```makefile
BIN_LIB=PR_TEST

all: download install

download:
	system "CRTLIB LIB($(BIN_LIB))"
	system "CRTSAVF FILE($(BIN_LIB)/PRUBY_BASE)"
	system "CRTSAVF FILE($(BIN_LIB)/PRUBY_0001)"
	system "CRTSAVF FILE($(BIN_LIB)/PRUBY_0006)"
	curl -L -k -o /QSYS.LIB/$(BIN_LIB).LIB/PRUBY_BASE.FILE https://github.com/PowerRuby/DE_train_01/releases/download/V2R0M0/pruby_base.savf
	curl -L -k -o /QSYS.LIB/$(BIN_LIB).LIB/PRUBY_0001.FILE https://github.com/PowerRuby/DE_train_01/releases/download/V2R0M0/pruby_0001.savf
	curl -L -k -o /QSYS.LIB/$(BIN_LIB).LIB/PRUBY_0006.FILE https://github.com/PowerRuby/DE_train_01/releases/download/V2R0M0/pruby_0006.savf

install:
	system "RSTLICPGM LICPGM(1PRUBY1) DEV(*SAVF) LNG(2924) SAVF($(BIN_LIB)/PRUBY_BASE)"
	system "RSTLICPGM LICPGM(1PRUBY1) DEV(*SAVF) LNG(2924) OPTION(1) SAVF($(BIN_LIB)/PRUBY_0001)"
	system "RSTLICPGM LICPGM(1PRUBY1) DEV(*SAVF) LNG(2924) OPTION(6) SAVF($(BIN_LIB)/PRUBY_0006)"
```

Then to install PowerRuby CE2 all the developer has to do is run `make`!

### Optional extras

PowerRuby also provides a version the GCC compiler (8.2) which is what they use to compile PR CE2 and some of the gems provided. It's also needed if you want to [compile 'native' gems](https://github.com/PowerRuby/DE_train_02).

```makefile
gcc:
	-system "CRTSAVF FILE($(BIN_LIB)/PRUBY_0002)"
	curl -L -k -o /QSYS.LIB/$(BIN_LIB).LIB/PRUBY_0002.FILE https://github.com/PowerRuby/DE_train_02/releases/download/V2R0M0/pruby_0002.savf
	system "RSTLICPGM LICPGM(1PRUBY1) DEV(*SAVF) LNG(2924) OPTION(2) SAVF($(BIN_LIB)/PRUBY_0002)"
```