-
-
Notifications
You must be signed in to change notification settings - Fork 196
Migrating an existing Alaveteli site from Ruby 2.7 to 3.x
From Alaveteli version 0.43 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 3.0 but we now also support 3.1 and the latest version 3.2 which we would recommend upgrading to.
Ensure you checkout the latest version of Alaveteli, as the alaveteli user, run:
cd /var/www/<your-alaveteli-install-dir>/alaveteli
git fetch
# either
git checkout release/0.43.0.0 # for the release candidate
# or
git checkout 0.43.0.0 # for the final release
# and then
git submodule update
The install script has been updated to allow Ruby to be upgraded automatically. Be aware this will also attempt to install all packages and configuration as if you're setting up a new server. This should not be used if you have custom configuration.
curl -O https://raw.githubusercontent.com/mysociety/commonlib/master/bin/install-site.sh
sudo sh install-site.sh alaveteli alaveteli alaveteli.192.168.64.2.nip.io
Then install required system packages to build Ruby:
cd /var/www/<your-alaveteli-install-dir>/alaveteli
xargs -a "config/packages.ruby-build" sudo apt-get -qq -y install
Then finally, again as the alaveteli user, run:
RBENV="$HOME/.rbenv"
RUBY_VERSION=3.2.2
if [ -d "$RBENV" ]; then
cd $RBENV && git pull --ff-only
cd $RBENV/plugins && git pull --ff-only
else
git clone https://github.com/rbenv/rbenv.git "$RBENV"
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
fi
rbenv install -s $RUBY_VERSION
rbenv global $RUBY_VERSION
gem install bundler
cd /var/www/<your-alaveteli-install-dir>/alaveteli
echo $RUBY_VERSION > .ruby-version
./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.
We need to edit /etc/init.d/alaveteli
, add the following to replace any lines starting with CMD=
and PATH=
:
CMD="bundle exec thin"
RBENV_ROOT="/home/alaveteli/.rbenv"
PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
CMD="cd $SITE_HOME; rbenv rehash; rbenv local 3.2.2; $CMD"
There are a number of file installed by Alaveteli which need updating manually.
/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 to replace any lines starting with RBENV_ROOT=
, PATH=
and SET_PATH=
:
RBENV_ROOT="/home/alaveteli/.rbenv"
PATH="$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH"
SET_PATH="cd $SITE_HOME; rbenv rehash; rbenv local 3.2.2"