# Rbenv

`Rbenv` is a ruby version management tool that allows you to handle several versions of ruby on a same machine. Combined with `ruby-build`, it also allows to install a given ruby version.

{% embed url="<https://github.com/rbenv/rbenv>" %}

## Installation

On MacOS, `Rbenv` can be installed using homebrew. It comes by default with ruby-build included.

```
$ brew install rbenv
```

Then init your rbenv environment:&#x20;

```
$ rbenv init
```

## Usage

### Install a given ruby version

```
# list all available versions:
$ rbenv install -l

# install a Ruby version:
$ rbenv install 2.0.0-p247
```

### Set the global ruby version

The version that will be used by default in your shell if no local version is specified.

```
$ rbenv global 1.8.7-p352
```

This will define the ruby version in `~/.rbenv/version`.

### Use a local ruby version

A version that will be used in a given directory/for a given project can be installed like this:

```
# in the directory you want to use the local ruby version 
$ rbenv local 1.9.3-p327
```

The ruby version is defined in a `.ruby-version` file in the given directory. Therefore, sharing a git repo with a `.ruby-version` file in the root directory will automatically set the ruby version used for the project.&#x20;

## Useful commands

```
# List all known ruby-versions (installed ones are marked by an asterisk)
$ rbenv versions

# Show the currently used ruby version
$ rbenv version
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://prospect-io.gitbook.io/developer-playbook/our-stack/ruby/rbenv.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
