Skip to content

Commit

Permalink
Update Ruby from 2.0.0 to 2.3.8
Browse files Browse the repository at this point in the history
Update all the installers (sysruby, RVM, rbenv, Travis CI).

Reasons against Ruby < 2.3 described in the previous commit. Ruby 2.3 is
itself old and has end-of-life scheduled for 2019-03-31. This is a
minimal temporary fix, the intention is to eventually update to the
latest Ruby version.

Rewrite the rbenv install script, use rbenv-installer from
https://github.com/rbenv/rbenv-installer and remove the old downloaded
copy which was from https://github.com/fesplugas/rbenv-installer
(archived: https://web.archive.org/web/20160414060830/https://raw.githubusercontent.com/fesplugas/rbenv-installer/master/bin/rbenv-installer).
  • Loading branch information
tom93 authored and Techno-coder committed Feb 15, 2020
1 parent b7f183a commit b55af35
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
rvm:
- "2.2.9"
- "2.3.8"
services:
- redis-server
- postgresql
Expand Down
65 changes: 0 additions & 65 deletions script/install/rbenv-installer

This file was deleted.

84 changes: 63 additions & 21 deletions script/install/rbenv.bash
Original file line number Diff line number Diff line change
@@ -1,34 +1,76 @@
#!/usr/bin/env bash

ruby_version=2.0.0-p353
ruby_version=2.3.8

# detect rbenv
rbenv --version &> /dev/null && {
# install ruby on rbenv
cmd="rbenv install $ruby_version"
echo "$ $cmd"
$cmd
rbenv --version &> /dev/null || {
# install rbenv using rbenv-installer

curl --version &> /dev/null || {
cmd="sudo apt-get install curl"
echo "$ $cmd"
$cmd || exit 1
}

source ~/.bashrc
cmd="rbenv global $ruby_version"
# suggested build environment (https://github.com/rbenv/ruby-build/wiki#suggested-build-environment)
cmd="sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev"
echo "$ $cmd"
$cmd
echo "Ruby $ruby_version installed, restart your session again and re-run this script"
exit 1
} || {
# install rvm
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$cmd || exit 1
# as suggested, try installing libgdbm5, if it is not available try with libgdbm3
# (it should have been installed as a dependency of libgdbm-dev anyway)
cmd="sudo apt-get install libgdbm5"
echo "$ $cmd"
$cmd || {
cmd="sudo apt-get install libgdbm3"
echo "$ $cmd"
$cmd || exit 1
}

# install ruby-build
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# rbenv-installer prints some instructions, make it clear what is
# output from rbenv-installer and what is output from this script.
echo "script/install/rbenv.bash: running rbenv-installer..."
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash
# ignore exit code because rbenv-installer runs rbenv-doctor, which is fussy and reports spurious errors
echo "script/install/rbenv.bash: rbenv-installer finished"
if ! [ -x ~/.rbenv/bin/rbenv ]; then
echo "rbenv-installer appears to have failed, please fix and re-run this script"
exit 1
fi

# add some bootstrap scripts
cat `dirname $0`/rbenv-installer | bash
# check if the user wants ~/.bashrc to be configured
# (try to detect if it's already been configured)
configure_bashrc=false
if ! grep -q 'PATH.*\.rbenv/bin' ~/.bashrc; then
# looks like it hasn't been configured yet
if bash script/confirm.bash "Configure ~/.bashrc"; then
configure_bashrc=true
fi
else
# looks like is has already been configured
echo "It looks like ~/.bashrc has already been configured (did you restart the session?)"
if DEFAULT=1 bash script/confirm.bash "Configure ~/.bashrc anyway"; then
configure_bashrc=true
fi
fi
# configure ~/.bashrc (if asked)
if $configure_bashrc; then
echo '$ echo '\''export PATH="$HOME/.rbenv/bin:$PATH"'\'' >> ~/.bashrc'
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo '$ echo '\''eval "$(rbenv init -)"'\'' >> ~/.bashrc'
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
fi

echo "rbenv installed, now restart the session and re-run this script"
echo "You might want to run a bootstrap script to install some ruby dependencies before installing a ruby, eg 'rbenv bootstrap-ubuntu-12-04'"
exit 1
}

# install ruby on rbenv
cmd="rbenv install $ruby_version"
echo "$ $cmd"
$cmd || exit 1

# TODO: consider using .ruby-version file for project instead of global version
cmd="rbenv global $ruby_version"
echo "$ $cmd"
$cmd || exit 1
echo "Ruby $ruby_version installed" # no need to restart session
8 changes: 4 additions & 4 deletions script/install/ruby.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
min_version=1.9.2
ruby -e 'puts RUBY_VERSION' 2>/dev/null | bash script/check_version.bash $min_version || {
echo "Ruby $min_version+ required!"
echo Select an install option for Ruby 1.9.3
echo "Select an install option for Ruby 2.3.8"

# detect RVM
rvm --version && rvm_option="Install Ruby using RVM" || rvm_option="Install RVM (Single User)"
rbenv --version && rbenv_option="Install Ruby using rbenv" || rbenv_option="Install rbenv (Single User on Desktop with ruby-build)"
select INSTALL_OPTION in "Don't install" "System MRI Ruby from source" "$rvm_option" "$rbenv_option";
rvm --version &>/dev/null && rvm_option="Install Ruby using RVM" || rvm_option="Install RVM (single user)"
rbenv --version &>/dev/null && rbenv_option="Install Ruby using rbenv" || rbenv_option="Install rbenv (single user with ruby-build)"
select INSTALL_OPTION in "Exit without installing" "System MRI Ruby from source" "$rvm_option" "$rbenv_option";
do
case $REPLY in
1)
Expand Down
2 changes: 1 addition & 1 deletion script/install/rvm.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

ruby_version=2.0.0
ruby_version=2.3.8

# detect rvm
rvm --version &> /dev/null && {
Expand Down
10 changes: 5 additions & 5 deletions script/install/sysruby.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env bash

# Installs the latest stable Ruby 2.0.x from source
branch="ruby-2.0-stable"
# Installs Ruby from source
branch="2.3"
version="ruby-2.3.8"
tmpdir="ruby_install"

# remember current directory
Expand All @@ -10,10 +11,9 @@ pdir=`pwd`
# download and extract source
cmd="mkdir /tmp/$tmpdir" ; echo "$ $cmd" ; $cmd || exit 1
cmd="cd /tmp/$tmpdir" ; echo "$ $cmd" ; $cmd || exit 1
cmd="wget http://ftp.ruby-lang.org/pub/ruby/$branch.tar.gz" ; echo "$ $cmd" ; $cmd || exit 1
cmd="wget https://cache.ruby-lang.org/pub/ruby/$branch/$version.tar.gz" ; echo "$ $cmd" ; $cmd || exit 1
cmd="mkdir src" ; echo "$ $cmd" ; $cmd
cmd="tar xvf $branch.tar.gz -C src" ; echo "$ $cmd" ; $cmd || exit 1
version=`ls src`
cmd="tar xvf $version.tar.gz -C src" ; echo "$ $cmd" ; $cmd || exit 1
cmd="mkdir build" ; echo "$ $cmd" ; $cmd || exit 1
cmd="cd build" ; echo "$ $cmd" ; $cmd || exit 1

Expand Down

0 comments on commit b55af35

Please sign in to comment.