On Ubuntu, you'll need to use the appropriate package manager (apt) to install dependencies and manage packages.
Here's how you can install Ruby using `rbenv` on Ubuntu:
1. **Install Dependencies**: Run the following command to install necessary dependencies for building Ruby:
$ sudo apt update
$ sudo apt install -y git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev
2. **Install rbenv**: If you haven't already installed `rbenv`, you can do so by cloning the rbenv repository into the `~/.rbenv` directory:
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Then add `rbenv` to your PATH by running:
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ source ~/.bashrc
3. **Install ruby-build**: Similarly, you can install the `ruby-build` plugin, which provides the `rbenv install` command:
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
4. **List Available Ruby Versions**: After setting up `rbenv` and `ruby-build`, you can list available Ruby versions:
$ rbenv install --list
Choose the desired Ruby version from the list and proceed with installation.
5. **Install Ruby**: Once you've chosen a Ruby version from the list, you can install it using `rbenv install`:
$ rbenv install <ruby_version>
Replace `<ruby_version>` with the version you want to install.
6. **Set Global Ruby Version**: After installing Ruby, you might want to set it as the global version:
$ rbenv global <ruby_version>
This will make the specified Ruby version the default version for your user.
Following these steps should allow you to install Ruby using `rbenv` on Ubuntu.
Comments
Post a Comment