rbenv /rbenv

Manage your app's Ruby environment

★ 16,743⑂ 1,423👁 287⑃ 443● 1,066▤ 14
ShellMITCreated 2011-08-01rbenv.org/
下载:rbenv 1.3.2rbenv-1.3.2 ↓1.3.22025-01-08
+1
日增长
16,743
stars
1,423
forks
287
watchers
443
prs
1,066
issues
14
releases

README

Seamlessly manage your app’s Ruby environment with rbenv.

rbenv is a version manager tool for the Ruby programming language on Unix-like systems. It is useful for switching between multiple Ruby versions on the same machine and for ensuring that each project you are working on always runs on the correct Ruby version.

 How It Works

After rbenv injects itself into your PATH at installation time, any invocation of ruby, gem, bundler, or other Ruby-related executable will first activate rbenv. Then, rbenv scans the current project directory for a file named .ruby-version. If found, that file determines the version of Ruby that should be used within that directory. Finally, rbenv looks up that Ruby version among those installed under ~/.rbenv/versions/.

You can choose the Ruby version for your project with, for example:
sh
cd myproject
 choose Ruby version 3.1.2:
rbenv local 3.1.2


Doing so will create or update the .ruby-version file in the current directory with the version that you've chosen. A different project of yours that is another directory might be using a different version of Ruby altogether—rbenv will seamlessly transition from one Ruby version to another when you switch projects.

Finally, almost every aspect of rbenv's mechanism is [customizable via plugins][plugins] written in bash.

The simplicity of rbenv has its benefits, but also some downsides. See the [comparison of version managers][alternatives] for more details and some alternatives.

 Installation

On systems with Homebrew package manager, the “Using Package Managers” method is recommended. On other systems, “Basic Git Checkout” might be the easiest way of ensuring that you are always installing the latest version of rbenv.

 Using Package Managers

1. Install rbenv using one of the following approaches.

    Homebrew
   
   On macOS or Linux, we recommend installing rbenv with Homebrew.
   
   sh
   brew install rbenv
   
   
    Debian, Ubuntu, and their derivatives
       
    [!CAUTION]   
    The version of rbenv that is packaged and maintained in official
    Debian and Ubuntu repositories is _out of date_. To install the latest
    version, it is recommended to install rbenv using git.
   
   sh
   sudo apt install rbenv
   
   
    Arch Linux and its derivatives
   
   Archlinux has an official package which you can install:

   sh
   sudo pacman -S rbenv
   

    Fedora

   Fedora has an official package which you can install:

   sh
   sudo dnf install rbenv
   

    OpenSUSE Tumbleweed

   OpenSUSE has an official package which you can install:

   sh
   sudo zypper in rbenv
   

2. Set up your shell to load rbenv.

    sh
    rbenv init
    

3. Close your Terminal window and open a new one so your changes take effect.

That's it! You are now ready to install some Ruby versions.

 Basic Git Checkout

 [!NOTE]   
 For a more automated install, you can use rbenv-installer. If you do not want to execute scripts downloaded from a web URL or simply prefer a manual 

Top issues

Discussions

Latest release

rbenv 1.3.2 v1.3.2 2025-01-08
What's Changed
 Fix traversing PATH for bash < 4.4 by @mislav in https://github.com/rbenv/rbenv/pull/1606

 Special shoutouts to
 @BiggerNoise for helping me debug rbenv init
 @Tobias-pwnr for reporting a bug with bash < 4.4
 @pnghai for the proposed fix 1605

Full Changelog: https://github.com/rbenv/rbenv/compare/v1.3.1...v1.3.2

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON