-
Notifications
You must be signed in to change notification settings - Fork 101
setup ruby and rbenv
If you would like to use the full capabilities of our toolchain you need to install and configure Ruby. The easiest way to get Ruby up and running is to follow our rbenv guide. Using rbenv will allow you to easily manage multiple ruby versions and gems(Ruby software packages) without affecting your system libraries.
This setup guide has been tested on OpenSUSE Leap versions 15.2, 15.1 and 15.0.
ℹ️
|
These requirements should be the same for most versions of OpenSUSE. If you come across any bugs please report them as a github issue at: Uyuni Docs Issues |
-
Install rbenv build prerequisites:
sudo zypper install automake gdbm-devel libyaml-devel sqlite3-devel \ ncurses-devel readline-devel zlib-devel git gcc libopenssl-devel
-
Once the prerequisites have finished installing open a terminal (You should be in your home directory). Clone the rbenv git repository:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
-
Next, add
~/.rbenv/bin
to your $PATH so that you can use the rbenv command line utility. Do this by altering your~/.bashrc file
so that it affects future login sessions:echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
-
Then add the command
eval "$(rbenv init -)"
to your~/.bashrc
file so rbenv loads automatically:echo 'eval "$(rbenv init -)"' >> ~/.bashrc
-
Next, apply the changes you made to your
~/.bashrc
file to your current shell session:source ~/.bashrc
-
Next, install the ruby-build, plugin. This plugin adds the rbenv install command, which simplifies the installation process for new versions of Ruby:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
-
Test that your installation is successful by typing
rbenv
on the command line. You should see the following output:guides@linux-059r:~> rbenv rbenv 1.1.2-2-g4e92322 Usage: rbenv <command> [<args>] Some useful rbenv commands are: commands List all available rbenv commands local Set or show the local application-specific Ruby version global Set or show the global Ruby version shell Set or show the shell-specific Ruby version install Install a Ruby version using ruby-build uninstall Uninstall a specific Ruby version rehash Rehash rbenv shims (run this after installing executables) version Show the current Ruby version and its origin versions List installed Ruby versions which Display the full path to an executable whence List all Ruby versions that contain the given executable See `rbenv help <command>' for information on a specific command. For full documentation, see: https://github.com/rbenv/rbenv#readme
At this point, you have both rbenv and ruby-build successfully installed. Let’s install Ruby next.
With the ruby-build plugin now installed, you can install multiple and any versions of Ruby you may need through a simple command.
-
First, let’s list all the available versions of Ruby:
rbenv install -l
-
The output of that command should be a long list of versions that you can choose to install. Scroll to the top or pipe the command through less to see a page at a time
rbenv install -l | less
. -
For our purposes we need to install Ruby 2.6.7 the latest stable version:
rbenv install 2.6.7
-
To set this specific version of ruby as your global version run the following command:
rbenv global 2.6.7
-
Verify that Ruby was properly installed by checking its version number:
ruby -v
If you installed version 2.6.7 of Ruby, your output to the above command should look something like this:
guides@linux-059r:~> ruby --version ruby 2.6.7p197 (2021-04-05 revision 67941) [x86_64-linux]
To install and use a different version of Ruby, run the rbenv commands with a different version number, as in rbenv install 2.5.0
and rbenv global 2.5.0
.
Once you install a new version of Ruby you will need to reinstall your gems, asciidoctor, asciidoctor-pdf etc as these are version specific and stored in an rbenv versioned directory.
You now have at least one version of Ruby installed and have set your default Ruby version. Next, we will set up asciidoctor and asciidoctor-pdf.
Continue to Install nvm