Menu

Migrating Redmine from system Ruby to RVM on CentOS

Redmine 4 is knocking on the door, and it’s going to drop support for anything below 2.2.2. Unfortunately, EL 7 only has 2.0.0, so you either wait until EL 8 releases and hope it comes with 2.2.2+, or you migrate from the packaged Ruby to something else.

I’m picking RVM, because reasons. If you use PostgreSQL 10 from the official upstream repo, make sure the devel package is installed:

yum -y install postgresql10-devel

Also make a symlink for easier access:

ln -s /usr/pgsql-10 /usr/pgsql

Make sure to keep this symlink updated, when you upgrade to a newer major release.

Stop Redmine first:

systemctl stop thin

At this point, it’s a wise idea to take a snapshot of your Redmine VM, because things will get shaky.

Nuke the old system Ruby gems:

gem cleanup
for x in $(gem list | cut -f 1 -d ' '); do gem uninstall $x -x -I -a; done
gem uninstall -I -x -i /usr/share/gems bigdecimal
gem uninstall -I -x -i /usr/share/gems io-console
gem uninstall -I -x -i /usr/share/gems json
rm -rf /usr/local/share/gems/build_info/*
rm -rf /usr/local/share/gems/cache/*
rm -rf /usr/local/share/gems/gems/*

Now install RVM:

curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -L get.rvm.io | bash -s stable

Now log out, then log back in, because new binaries are added, PATH is modified, etc.

Then find out the latest supported Ruby version for your Redmine instance, and install Ruby via RVM (fix RUBY_VER):

export RUBY_VER='x.y.z'
rvm requirements run
rvm install ${RUBY_VER}
rvm use ${RUBY_VER} --default
rvm all-gemsets do gem update bundler

Install the Redmine gems:

cd /opt/redmine
bundle config build.nokogiri --use-system-libraries
bundle config build.pg --with-pg-include=/usr/pgsql/include --with-pg-lib=/usr/pgsql/lib
bundle update
bundle install --verbose --without development test

Fix up Thin:

ln -s /usr/local/rvm/gems/default/wrappers/thin /usr/local/bin/thin
systemctl start thin && tail -f /var/log/thin/thin.8080.log

And that’s it, you’re running Redmine on fresh new shiny Ruby! All that’s left is wait for Redmine 4 to be released 🙂

Tags: , , , , ,