Skip to content

Migrating an existing Alaveteli site from Ruby 2.3 and 2.4

Graeme Porteous edited this page Jun 21, 2021 · 2 revisions

From Alaveteli version 0.39 we have dropped support for some older Ruby versions. These were no longer support and won't see any patches for security issues and other bug fixes.

Alaveteli's minimally supported version now is Ruby 2.5 - this version has also reached it's end-of-life so we would recommend upgrading to at least version 2.6.

To get newer version of Ruby there are a couple of options to consider.

1. Upgrading your Debian or Ubuntu distribution.

The easiest way would be to upgrade your Linux distribution to either:

  • Debian 10 (Buster)
  • Ubuntu 18.04 (Bionic)

These both come with Ruby 2.5 installed as default and although we recommend running Alaveteli on Ruby 2.6 we will still support version 2.5 for several more releases.

2. Keep your current distribution and manually install newer Ruby (via Rbenv)

Ensure you checkout the latest version of Alaveteli, as the alaveteli user, run:

  cd /var/www/alaveteli/alaveteli
  git fetch
  git checkout 0.39.0.0

Then install required system packages to build Ruby, as an admin user run:

  xargs -a "/var/www/alaveteli/alaveteli/config/packages.ruby-build" sudo apt-get -qq -y install

Then finally, again as the alaveteli user, run:

  RBENV="$HOME/.rbenv"
  RUBY_VERSION=2.6.7

  git clone https://github.com/rbenv/rbenv.git "$RBENV"
  cd $RBENV && src/configure && make -C src
  mkdir -p "$RBENV/plugins"
  git clone https://github.com/rbenv/ruby-build.git "$RBENV/plugins/ruby-build"

  echo "export PATH=\"$RBENV/bin:\$HOME/.gem/ruby/$RUBY_VERSION/bin:\$PATH\"" >> $HOME/.bashrc
  echo "eval \"\$(rbenv init -)\"" >> $HOME/.bashrc
  source $HOME/.bashrc

  rbenv install -s $RUBY_VERSION
  rbenv global $RUBY_VERSION
  gem install bundler

  cd /var/www/alaveteli/alaveteli
  ./script/rails-deploy-before-down

This will ensure you have the required version of Ruby and all the gems installed.

Next we need to upgrade the environment PATH in the crontab and init scripts.

Update Alaveteli init script

We need to edit /etc/init.d/alaveteli, replace bundle exec thin with $CMD throughout the file.

Then add the following after the line starting with PATH=:

CMD="bundle exec thin"
RBENV_ROOT="/home/alaveteli/.rbenv"
PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
CMD="cd /var/www/alaveteli/alaveteli; rbenv rehash; rbenv local 2.6.7; $CMD"

Update Crontab and other init scripts

There are a number of file installed by Alaveteli which need updating manually.

  • /etc/cron.d/alaveteli
  • /etc/init.d/alaveteli-alert-tracks
  • /etc/init.d/alaveteli-poll-for-incoming
  • /etc/init.d/alaveteli-send-notifications

These all require the PATH to Rbenv to be set, add the following after the line starting with PATH=:

RBENV_ROOT="/home/alaveteli/.rbenv"
PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
SET_PATH="cd /var/www/alaveteli/alaveteli; rbenv rehash; rbenv local 2.6.7"
Clone this wiki locally