Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruby 2 for Debian Wheezy

Ruby 2 for Debian Wheezy

The Problem

Debian Wheezy provides Ruby version 1.9.3. If you want to install a newer version, you need to do that manually. But you don't want to mess with your system Ruby. There are Ruby version managers like rbenv to solve that problem. Unfortunately, Debian's rbenv is out of date as well. You will need to install a newer version of rbenv and the ruby-build plugin.

The Solution

You can install the latest rbenv in your home directory. Execute the following commands as normal user, not as root.

# Backup your .rbenv folder if you have any
test -e "$HOME/.rbenv" && mv "$HOME/.rbenv" "$HOME/.rbenv.debian"

# Get the newest rbenv and the ruby-build plugin
git clone https://github.com/sstephenson/rbenv.git $HOME/.rbenv
git clone https://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build

# Use the new rbenv
PATH="$HOME/.rbenv/bin:$PATH"
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bashrc

# List available Ruby versions
rbenv install -l

# Install a newer Ruby version
rbenv install 2.4.1

# Use the new Ruby version
rbenv global 2.4.1

source ~/.bashrc
@brolin-empey

This comment has been minimized.

Copy link

@brolin-empey brolin-empey commented Aug 22, 2020

Thank you very much for these instructions. My company needs to run Jekyll on our on-site server, which still runs Debian 7.1, but Jekyll needs at least Ruby 2.5.0. Only Debian 10 and newer include at least Ruby 2.5.0 but I now have Jekyll running with Ruby 2.7.1 on Debian 7.1 thanks to you. We actually did try upgrading a different installation of Debian 7 on a client (as opposed to server, not as in customer) computer in place from Debian 7 to 8, 8 to 9, 9 to 10 but the resulting Debian 10 installation was partially broken so I started over with a new installation of Debian 10 for two client (as opposed to server, not as in customer) computers (I cloned the drive, did not do everything twice) but it is not feasible to upgrade our server from Debian 7.1 to Debian 10 only to get a newer version of Ruby.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment