Install ruby with rbenv and ruby-build
To install Ruby using ruby-build
and rbenv
, you can follow these steps:
-
First, make sure you have
ruby-build
andrbenv
installed on your system. You can check if you have them installed by running the following commands in your terminal:which ruby-build which rbenv
If either of these commands returns a path, it means that the corresponding tool is already installed on your system. If not, you can follow the installation instructions for your operating system.
-
Next, check if the version of Ruby you want to install is available in
ruby-build
. You can do this by running the following command:ruby-build --definitions | grep <version ``` Replace `<version>` with the version of Ruby you want to install. If the version is available in `ruby-build`, you can proceed to step 3. Otherwise, you will need to wait for the update to become available in `ruby-build`, or you can try installing Ruby manually.
-
Install the Ruby version using
rbenv
andruby-build
:rbenv install <version>
Replace
<version>
with the version of Ruby you want to install. This will download the Ruby source code and compile it, which may take some time. -
Once the installation is complete, you can set the global version of Ruby to use:
rbenv global <version>
This will set the global version of Ruby to the version you just installed.
-
Finally, verify that Ruby was installed correctly by running the following command:
ruby -v
This should display the version of Ruby you just installed.
If the version of Ruby you want to install is not available in ruby-build
yet,
but it is available in the official release, you can download the source code
from the Ruby website and compile it manually. Once you have the source code,
you can use ruby-build
to compile and install it:
-
Download the Ruby source code from the official Ruby website: https://www.ruby-lang.org/en/downloads
-
Extract the source code to a directory of your choice.
-
Use
ruby-build
to compile and install the Ruby version:ruby-build <path/to/source/code> <install/path>
Replace
<path/to/source/code>
with the path to the directory containing the extracted source code, and<install/path>
with the path where you want to install Ruby. -
Once the installation is complete, you can set the global version of Ruby to use:
rbenv global <version>
Replace
<version>
with the version of Ruby you just installed. -
Finally, verify that Ruby was installed correctly by running the following command:
ruby -v
This should display the version of Ruby you just installed.