DEV Community

@kon_yu
@kon_yu

Posted on • Updated on

Installing the latest version of Ruby on Raspberry pi

First

  • This is almost the same way to install in Debian.
  • Please be patient because it may take several hours to install Razpai because the spec is low.

Prerequisites

  • Body: Raspberry Pi 1 Model B+
  • Memory card: 8GB
  • OS: Latest version of Raspbian installed

rbenv installation

Install rbenv and write the configuration to the bash configuration file, if you use zsh, etc.

> sudo apt-get install rbenv
> echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bashrc
> echo 'eval "$(rbenv init -)"' >> .bashrc
Enter fullscreen mode Exit fullscreen mode

Confirmation of installation

> rbenv
> rbenv x.x.x #version to be displayed
Enter fullscreen mode Exit fullscreen mode

Installing ### git

If git is not installed, install git.

> sudo apt-get install git
Enter fullscreen mode Exit fullscreen mode

Install ruby-build

I'm going to clone ruby-build from git.

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

> rbenv install --list
there are 2.3.1 and the latest version of Cruby 2.3

rbenv install 2.3.1
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

If you don't have enough libraries in your Ruby installation, you can try to add them by using the following command

> sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
Enter fullscreen mode Exit fullscreen mode

Reference: https://github.com/rbenv/ruby-build/wiki#suggested-build-environment

If you installed ruby-build with apt-get

Even if I install ruby-build by apt-get, there is no latest version of Ruby in the list of available installables.
At runtime, ruby-2.2.0-preview is the latest version, and there is no 2.3 system of the latest version at this time.

> sudo apt-get install ruby-build
> rbenv install --list
Enter fullscreen mode Exit fullscreen mode

To uninstall ruby-build, click here

> sudo apt-get remove ruby-build
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
nerdcraftmuc profile image
nerdcraft-muc

Hi kon_yu,
I strictly followed your instructions and now there seems to bee a working ruby installation in /versions/3.2.0 but the system still runs the old ruby version 2.3.3.

Any idea what I can try?

BTW: I am not really a Linux expert.

Thanks in advance!

Rick

Collapse
 
konyu profile image
@kon_yu

Thank you for your comment.

Did you set global version setting? Like below
rbenv global 3.2.0

Another tips

rbenv rehash
Or
reload shell
exec $SHELL -l