Multiple Ruby versions
Using a Ruby version manager is critical if you plan on running many projects with different Ruby version. A project might not be compatible with the version of Ruby you have installed. We need a way to switch between versions of Ruby without installing and uninstalling them every time.
We need a way to switch between versions of Ruby without installing and uninstalling them every time.
There are two different ways to install and run multiple Ruby versions.
Host Mode - Install and run Ruby within host or virtual machine by Ruby Version Manager(RVM), asdf or rbenv.
Container Mode - Install and run Ruby within container by Docker and Docker Compose, or Kuberneters(K8S).
Xcode Command Line Tools
The Xcode Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS which is consists of the macOS SDK and command-line tools such as Clang, which are installed at this
For more information about installing and using Xcode Command Line Tools, see the Xcode Command Line Tools
Homebrew is the Missing Package Manager for macOS (or Linux).
For more information about installing and using Homebrew, see the Homebrew - https://brew.sh/.
1. Host Mode
Install and run Ruby within host or virtual machine by Ruby Version Manager(RVM), asdf or rbenv.
1.1. Ruby Version Manager(RVM)
Ruby Version Manager(RVM) is a command-line tool which allows you to easily install, manage, and work with multiple Ruby environments from interpreters to sets of gems.
Install GPG keys
Manage multiple runtime versions with a single CLI tool, extendable via plugins - docs at asdf-vm.com.
asdf is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like gvm, nvm, rbenv & pyenv (and more) all in one! Simply install your language’s plugin!
Install asdf dependencies
Install asdf Ruby Plugin.
Install Ruby plugin requirements
Update Ruby plugin.
asdf plugin update ruby
List all Ruby versions.
asdf list all ruby
Install a Ruby version manually.
asdf install ruby 2.7.2
See follow links to learn more:
Groom your app’s Ruby environment with rbenv.
Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with Bundler for painless Ruby upgrades and bulletproof deployments.
Compatibility note: rbenv is incompatible with RVM. Please make sure to fully uninstall RVM and remove any references to it from your shell initialization files before installing rbenv.
2. Container Mode
Install and run Ruby within container by Docker and Docker Compose, or Kuberneters(K8S).
2.1 Docker and Docker Compose
Create or update
Build docker image and run container.
docker build -t my-ruby-app .
docker-compose.yml describes the services that comprise your app (a database and a web app), how to get each one’s Docker image (the database just runs on a pre-made PostgreSQL image, and the web app is built from the current directory), and the configuration needed to link them together and expose the web app’s port.
You can now boot the app with docker-compose up:
See follow links to learn more.
2.2 Kubernetes (K8S)
Create or update k8s manifests file
kubectl create -f k8s.yml
 [Deploying Ruby on Rails Apps on Kubernetes | Littlelines - https://littlelines.com/blog/2020/04/08/deploying-ruby-on-rails-apps-on-kubernetes)(https://littlelines.com/blog/2020/04/08/deploying-ruby-on-rails-apps-on-kubernetes)