Install and use the latest version of Ruby - ruby

I am making a script to install the latest stable ruby using rvm. I use:
rvm install ruby --latest
But the problem is, since I do not know which version is going to be installed, I do not know how to use rvm use to set it as the default ruby version.
How could I solve this?

You can do
rvm use ruby --latest --default

Related

how to completely uninstall ruby if it has been install as a system at a Mac?

I has been install a ruby version 3.1.2 at my Mac computer and I want to uninstall it completely.
When I check by this command
which -a ruby
It show me this
/Users/nguyencuc/.rubies/ruby-3.1.2/bin/ruby
/usr/bin/ruby
So, as this page said, https://mac.install.guide/ruby/9.html, maybe it is a system ruby ?
So how can I completely uninstall this ruby to install another version of ruby ? Could you please give me some advices ? Thank you very much for your time.
As you have installed ruby, not using rbenv or rvm, there are two ways through which you can remove it.
Using Command brew uninstall --force ruby
Or you have to manually remove the ruby files from your system. Type whereis ruby to find where it is installed and then remove the files using rm
If you have installed ruby via Rbenv, type this:
rbenv uninstall 3.1.2
For installing another version, type:
rbenv install *version*

How to know the lastest version of ruby in Terminal?

I intend to install ruby by rvm to my Macbook Pro, with the command tutorial:
$ rvm requirements
$ rvm install 2.3.0
$ rvm use 2.3.0 --default
But you know the 2.3.0 maybe not the newest version, because the tutorial is long time ago.
So, how can I get the lastest version of ruby in command?
rvm get head # update list of known rubies. Necessary if your local list is out of date.
rvm install ruby --latest # install the latest ruby
The latest ruby version (at time of writing) is 2.4.0
you can run rvm list known to see all options, but 2.3 is pretty new and will be a good choice.

Upgrading to latest version of Ruby

I understand that rvm allows us to run multiple versions of ruby. Are ruby gems installed to a specific version of ruby? Say I upgraded to the latest version of ruby 2.1.1 and want to use that as my default, do I have to reinstall the ruby gems from the earlier version of ruby to this version?
If you use rvm install, you will have to install your gems anew. If you use rvm upgrade, the gems will be migrated if possible.
Check out the RVM documentation:
RVM creates a new completely separate gem directory for each version of ruby. In addition you can separate this further and have a set of gems per project/application/gerbil color... see the gemsets for more details on using sets of gems. [...]
rvm --default use <RUBYVERSION>
For example,
rvm --default use 2.1.1
You can check this. And check out RVM Documentation too.

rvm determine and install latest version of ruby

So far I only know how to do commands like
rvm 2.0.0
Fortunately Google tells me
The current stable version is 2.0.0-p247.
But shouldn't I be able to use rvm to do that step for me? I can't figure out how to just tell rvm to install the latest version of ruby, without manually specifying it.
it is enough to:
rvm get stable
rvm use ruby --install --default
it will update rvm, check for latest ruby - install it if missing - and set as default
I don't know of a way to have rvm just install the latest version automatically, but here's three simple commands using just rvm:
rvm reload
rvm list known # This will show all the available versions, including the latest
rvm install <latest_version> # Replace <latest_version> with the latest shown by the last command
rvm install ruby-head should install the last known version.

how to install two versions of the RVM

I use a very old ruby 1.8.7 which is installed only very old RVM 1.6.9, and I would like to install a new Ruby but my RVM only knows about Ruby 1.9.2 version. I would like to put a new version of the RVM kept the old one, but there is a conflict. Please tell me how to put a new version of Ruby without deleting the old one?
p.s. I installed rvm from ubuntu repositories
You are using old and broken (by Ubuntu) package of RVM, please use this instructions to update https://stackoverflow.com/a/9056395/497756
Why don't you simply update your rvm? You can do this by
rvm update --head
or
rvm get head --auto
According to your RVM version.

Resources