Skip to content

Instantly share code, notes, and snippets.

@alexishida
Last active July 23, 2024 02:43
Show Gist options
  • Save alexishida/015b074ae54e1c7101335a2a63518924 to your computer and use it in GitHub Desktop.
Save alexishida/015b074ae54e1c7101335a2a63518924 to your computer and use it in GitHub Desktop.
Script to update rbenv, Ruby and Ruby on Rails versions
#!/bin/bash
#---------------------------------------------------------------------------------------
# Script to update rbenv, Ruby and Ruby on Rails versions
# Source: https://gist.github.com/alexishida/015b074ae54e1c7101335a2a63518924
#
# Author: Alex Ishida <alexishida@gmail.com>
# Version: 1.6.1 - 22/07/2024
#---------------------------------------------------------------------------------------
#
# If you want install rbenv for the first time
# DO NOT EXECUTE THIS SCRIPT please use this:
# https://gist.github.com/alexishida/655fb139c759393ae5fe47dacd163f99
#
#---------------------------------------------------------------------------------------
#
# HOW TO INSTALL A SCRIPT
#
# - Ruby <= 2.6 require Ubuntu <= 20.04 (require openssl1.1.1 don't work on openssl3.0)
# - Ruby 3.0 works with Ubuntu 22.04
#
# - Download Raw rbenv-ruby-rails-update.sh from Gist
#
# - Change permission to run script
# $ chmod +x rbenv-ruby-rails-update.sh
#
# - DO NOT Execute script with sudo
# $ ./rbenv-ruby-rails-update.sh
#
# - Reload terminal (Bash or Zsh)
# $ bash or $ zsh
#
#---------------------------------------------------------------------------------------
#
# If you want to remove older ruby version run the commands below:
# $ rbenv versions
# $ rbenv uninstall <version>
#
#---------------------------------------------------------------------------------------
# Set Latest Ruby Version
RUBY_VERSION=3.3.4
# Checking if script running with sudo
if [[ $(id -u) -eq 0 ]]
then echo "Please DO NOT run with sudo ..."
exit 1
fi
# Change crlf git
git config --global core.autocrlf false
echo "Updating rbenv ..."
cd /usr/local/rbenv
git reset --hard
git pull origin master
echo "Updating ruby-build .."
cd ~/.rbenv/plugins/ruby-build
git reset --hard
git pull origin master
echo "Installing ruby version $RUBY_VERSION"
rbenv install -v "$RUBY_VERSION"
rbenv global "$RUBY_VERSION"
rbenv rehash
echo "Installing rails"
gem install bundler
gem update --system
# Install gems to use in vscode
gem install ruby-debug-ide
gem install debase
gem install readapt
gem install solargraph
gem install rufo # Ruby Formater
gem install rails
echo 'Installation completed :D'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment