{"id":13400512,"url":"https://github.com/rbenv/rbenv","last_synced_at":"2025-12-16T16:42:26.296Z","repository":{"id":38078145,"uuid":"2139017","full_name":"rbenv/rbenv","owner":"rbenv","description":"Manage your app's Ruby environment","archived":false,"fork":false,"pushed_at":"2025-04-01T06:59:36.000Z","size":691,"stargazers_count":16343,"open_issues_count":12,"forks_count":1411,"subscribers_count":295,"default_branch":"master","last_synced_at":"2025-04-23T20:58:35.446Z","etag":null,"topics":["bash","ruby","ruby-installation","ruby-versions","shell"],"latest_commit_sha":null,"homepage":"https://rbenv.org/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rbenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-08-01T20:51:48.000Z","updated_at":"2025-04-23T16:58:25.000Z","dependencies_parsed_at":"2023-01-29T20:15:25.026Z","dependency_job_id":"d9d30474-5775-41ef-abfc-6bcfa8e8c59f","html_url":"https://github.com/rbenv/rbenv","commit_stats":{"total_commits":594,"total_committers":127,"mean_commits":4.677165354330708,"dds":0.6986531986531986,"last_synced_commit":"a632465cf4007d0a5b419ed5c5a7bd87349d7b14"},"previous_names":["sstephenson/rbenv"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbenv%2Frbenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbenv%2Frbenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbenv%2Frbenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rbenv%2Frbenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rbenv","download_url":"https://codeload.github.com/rbenv/rbenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","ruby","ruby-installation","ruby-versions","shell"],"created_at":"2024-07-30T19:00:52.812Z","updated_at":"2025-12-16T16:42:21.232Z","avatar_url":"https://github.com/rbenv.png","language":"Shell","readme":"# Seamlessly manage your app’s Ruby environment with rbenv.\n\nrbenv 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.\n\n## How It Works\n\nAfter 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/`.\n\nYou can choose the Ruby version for your project with, for example:\n```sh\ncd myproject\n# choose Ruby version 3.1.2:\nrbenv local 3.1.2\n```\n\nDoing 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.\n\nFinally, almost every aspect of rbenv's mechanism is [customizable via plugins][plugins] written in bash.\n\nThe simplicity of rbenv has its benefits, but also some downsides. See the [comparison of version managers][alternatives] for more details and some alternatives.\n\n## Installation\n\nOn 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.\n\n### Using Package Managers\n\n1. Install rbenv using one of the following approaches.\n\n   #### Homebrew\n   \n   On macOS or Linux, we recommend installing rbenv with [Homebrew](https://brew.sh).\n   \n   ```sh\n   brew install rbenv\n   ```\n   \n   #### Debian, Ubuntu, and their derivatives\n       \n   \u003e [!CAUTION]   \n   \u003e The version of rbenv that is packaged and maintained in official\n   Debian and Ubuntu repositories is _out of date_. To install the latest\n   version, it is recommended to [install rbenv using git](#basic-git-checkout).\n   \n   ```sh\n   sudo apt install rbenv\n   ```\n   \n   #### Arch Linux and its derivatives\n   \n   Archlinux has an [official package](https://archlinux.org/packages/extra/any/rbenv/) which you can install:\n\n   ```sh\n   sudo pacman -S rbenv\n   ```\n\n   #### Fedora\n\n   Fedora has an [official package](https://packages.fedoraproject.org/pkgs/rbenv/rbenv/) which you can install:\n\n   ```sh\n   sudo dnf install rbenv\n   ```\n\n2. Set up your shell to load rbenv.\n\n    ```sh\n    rbenv init\n    ```\n\n3. Close your Terminal window and open a new one so your changes take effect.\n\nThat's it! You are now ready to [install some Ruby versions](#installing-ruby-versions).\n\n### Basic Git Checkout\n\n\u003e [!NOTE]   \n\u003e For a more automated install, you can use [rbenv-installer](https://github.com/rbenv/rbenv-installer#rbenv-installer). If you do not want to execute scripts downloaded from a web URL or simply prefer a manual approach, follow the steps below.\n\nThis will get you going with the latest version of rbenv without needing a system-wide install.\n\n1. Clone rbenv into `~/.rbenv`.\n\n    ```sh\n    git clone https://github.com/rbenv/rbenv.git ~/.rbenv\n    ```\n\n2. Set up your shell to load rbenv.\n\n    ```sh\n    ~/.rbenv/bin/rbenv init\n    ```\n\n   If you are curious, see here to [understand what `init` does](#how-rbenv-hooks-into-your-shell).\n\n3. Restart your shell so that these changes take effect. (Opening a new terminal tab will usually do it.)\n\n#### Shell completions\n\nWhen _manually_ installing rbenv, it might be useful to note how completion scripts for various shells work. Completion scripts help with typing rbenv commands by expanding partially entered rbenv command names and option flags; typically this is invoked by pressing \u003ckbd\u003eTab\u003c/kbd\u003e key in an interactive shell.\n\n- The **bash** completion script for rbenv ships with the project and gets [loaded by the `rbenv init` mechanism](#how-rbenv-hooks-into-your-shell).\n\n- The **zsh** completion script ships with the project, but needs to be added to FPATH in zsh before it can be discovered by the shell. One way to do this would be to edit `~/.zshrc`:\n\n  ```sh\n  # assuming that rbenv was installed to `~/.rbenv`\n  FPATH=~/.rbenv/completions:\"$FPATH\"\n\n  autoload -U compinit\n  compinit\n  ```\n\n- The **fish** completion script for rbenv ships with the fish shell itself and is not maintained by the rbenv project.\n\n### Installing Ruby versions\n\nThe `rbenv install` command does not ship with rbenv out-of-the-box, but is provided by the [ruby-build][] plugin.\n\nBefore attempting to install Ruby, **check that [your build environment](https://github.com/rbenv/ruby-build/wiki#suggested-build-environment) has the necessary tools and libraries**. Then:\n\n```sh\n# list latest stable versions:\nrbenv install -l\n\n# list all local versions:\nrbenv install -L\n\n# install a Ruby version:\nrbenv install 3.1.2\n```\n\nFor troubleshooting `BUILD FAILED` scenarios, check the [ruby-build Discussions section](https://github.com/rbenv/ruby-build/discussions/categories/build-failures).\n\n\u003e [!NOTE]  \n\u003e If the `rbenv install` command wasn't found, you can install ruby-build as a plugin:\n\u003e ```sh\n\u003e git clone https://github.com/rbenv/ruby-build.git \"$(rbenv root)\"/plugins/ruby-build\n\u003e ```\n\nSet a Ruby version to finish installation and start using Ruby:\n```sh\nrbenv global 3.1.2   # set the default Ruby version for this machine\n# or:\nrbenv local 3.1.2    # set the Ruby version for this directory\n```\n\nAlternatively to the `rbenv install` command, you can download and compile Ruby manually as a subdirectory of `~/.rbenv/versions`. An entry in that directory can also be a symlink to a Ruby version installed elsewhere on the filesystem.\n\n#### Installing Ruby gems\n\nSelect a Ruby version for your project using `rbenv local 3.1.2`, for example. Then, proceed to install gems as you normally would:\n\n```sh\ngem install bundler\n```\n\n\u003e [!NOTE]  \n\u003e You _should not use sudo_ to install gems. Typically, the Ruby versions will be installed under your home directory and thus writeable by your user. If you get the “you don't have write permissions” error when installing gems, it's likely that your \"system\" Ruby version is still a global default. Change that with `rbenv global \u003cversion\u003e` and try again.\n\nCheck the location where gems are being installed with `gem env`:\n\n```sh\ngem env home\n# =\u003e ~/.rbenv/versions/\u003cversion\u003e/lib/ruby/gems/...\n```\n\n#### Uninstalling Ruby versions\n\nAs time goes on, Ruby versions you install will accumulate in your\n`~/.rbenv/versions` directory.\n\nTo remove old Ruby versions, simply `rm -rf` the directory of the\nversion you want to remove. You can find the directory of a particular\nRuby version with the `rbenv prefix` command, e.g. `rbenv prefix\n2.7.0`.\n\nThe [ruby-build][] plugin provides an `rbenv uninstall` command to\nautomate the removal process.\n\n## Command Reference\n\nThe main rbenv commands you need to know are:\n\n### rbenv versions\n\nLists all Ruby versions known to rbenv, and shows an asterisk next to\nthe currently active version.\n\n    $ rbenv versions\n      1.8.7-p352\n      1.9.2-p290\n    * 1.9.3-p327 (set by /Users/sam/.rbenv/version)\n      jruby-1.7.1\n      rbx-1.2.4\n      ree-1.8.7-2011.03\n\n### rbenv version\n\nDisplays the currently active Ruby version, along with information on\nhow it was set.\n\n    $ rbenv version\n    1.9.3-p327 (set by /Users/sam/.rbenv/version)\n\n### rbenv local\n\nSets a local application-specific Ruby version by writing the version\nname to a `.ruby-version` file in the current directory. This version\noverrides the global version, and can be overridden itself by setting\nthe `RBENV_VERSION` environment variable or with the `rbenv shell`\ncommand.\n\n    rbenv local 3.1.2\n\nWhen run without a version number, `rbenv local` reports the currently\nconfigured local version. You can also unset the local version:\n\n    rbenv local --unset\n\n### rbenv global\n\nSets the global version of Ruby to be used in all shells by writing\nthe version name to the `~/.rbenv/version` file. This version can be\noverridden by an application-specific `.ruby-version` file, or by\nsetting the `RBENV_VERSION` environment variable.\n\n    rbenv global 3.1.2\n\nThe special version name `system` tells rbenv to use the system Ruby\n(detected by searching your `$PATH`).\n\nWhen run without a version number, `rbenv global` reports the\ncurrently configured global version.\n\n### rbenv shell\n\nSets a shell-specific Ruby version by setting the `RBENV_VERSION`\nenvironment variable in your shell. This version overrides\napplication-specific versions and the global version.\n\n    rbenv shell jruby-1.7.1\n\nWhen run without a version number, `rbenv shell` reports the current\nvalue of `RBENV_VERSION`. You can also unset the shell version:\n\n    rbenv shell --unset\n\nNote that you'll need rbenv's shell integration enabled (step 3 of\nthe installation instructions) in order to use this command. If you\nprefer not to use shell integration, you may simply set the\n`RBENV_VERSION` variable yourself:\n\n    export RBENV_VERSION=jruby-1.7.1\n\n### rbenv rehash\n\nInstalls shims for all Ruby executables known to rbenv (`~/.rbenv/versions/*/bin/*`). Typically you do not need to run this command, as it will run automatically after installing gems.\n\n    rbenv rehash\n\n### rbenv which\n\nDisplays the full path to the executable that rbenv will invoke when\nyou run the given command.\n\n    $ rbenv which irb\n    /Users/sam/.rbenv/versions/1.9.3-p327/bin/irb\n\n### rbenv whence\n\nLists all Ruby versions that contain the specified executable name.\n\n    $ rbenv whence rackup\n    1.9.3-p327\n    jruby-1.7.1\n    ree-1.8.7-2011.03\n\n## Environment variables\n\nYou can affect how rbenv operates with the following settings:\n\nname | default | description\n-----|---------|------------\n`RBENV_VERSION` | | Specifies the Ruby version to be used.\u003cbr\u003eAlso see [`rbenv shell`](#rbenv-shell)\n`RBENV_ROOT` | `~/.rbenv` | Defines the directory under which Ruby versions and shims reside.\u003cbr\u003eAlso see `rbenv root`\n`RBENV_DEBUG` | | Outputs debug information.\u003cbr\u003eAlso as: `rbenv --debug \u003csubcommand\u003e`\n`RBENV_HOOK_PATH` | [_see wiki_][hooks] | Colon-separated list of paths searched for rbenv hooks.\n`RBENV_DIR` | `$PWD` | Directory to start searching for `.ruby-version` files.\n\n### How rbenv hooks into your shell\n\n`rbenv init` is a helper command to hook rbenv into a shell. This helper is part of the recommended installation instructions, but optional, as an experienced user can set up the following tasks manually. The `rbenv init` command has two modes of operation:\n\n1. `rbenv init`: made for humans, this command edits your shell initialization files on disk to add rbenv to shell startup. (Prior to rbenv 1.3.0, this mode only printed user instructions to the terminal, but did nothing else.)\n\n2. `rbenv init -`: made for machines, this command outputs a shell script suitable to be eval'd by the user's shell.\n\nWhen `rbenv init` is invoked from a bash shell, for example, it will add the following to the user's `~/.bashrc` or `~/.bash_profile`:\n\n```sh\n# Added by `rbenv init` on \u003cDATE\u003e\neval \"$(rbenv init - --no-rehash bash)\"\n```\n\nYou may add this line to your shell initialization files manually if you want to avoid running `rbenv init` as part of the setup process. Here is what the eval'd script does:\n\n0. Adds `rbenv` executable to PATH if necessary.\n\n1. Prepends `~/.rbenv/shims` directory to PATH. This is basically the only requirement for rbenv to function properly.\n\n2. Installs bash shell completion for rbenv commands.\n\n3. Regenerates rbenv shims. If this step slows down your shell startup, you can invoke `rbenv init -` with the `--no-rehash` flag.\n\n4. Installs the \"sh\" dispatcher. This bit is also optional, but allows rbenv and plugins to change variables in your current shell, making commands like `rbenv shell` possible.\n\n\n### Uninstalling rbenv\n\nThe simplicity of rbenv makes it easy to temporarily disable it, or\nuninstall from the system.\n\n1. To **disable** rbenv managing your Ruby versions, simply comment or remove the `rbenv init` line from your shell startup configuration. This will remove rbenv shims directory from PATH, and future invocations like `ruby` will execute the system Ruby version, bypassing rbenv completely.\n\n   While disabled, `rbenv` will still be accessible on the command line, but your Ruby apps won't be affected by version switching.\n\n2. To completely **uninstall** rbenv, perform step (1) and then remove the rbenv root directory. This will **delete all Ruby versions** that were installed under `` `rbenv root`/versions/ ``:\n\n       rm -rf \"$(rbenv root)\"\n\n   If you've installed rbenv using a package manager, as a final step\n   perform the rbenv package removal:\n   - Homebrew: `brew uninstall rbenv`\n   - Debian, Ubuntu, and their derivatives: `sudo apt purge rbenv`\n   - Archlinux and its derivatives: `sudo pacman -R rbenv`\n\n## Development\n\nTests are executed using [Bats](https://github.com/bats-core/bats-core):\n\n    $ bats test\n    $ bats test/\u003cfile\u003e.bats\n\nPlease feel free to submit pull requests and file bugs on the [issue\ntracker](https://github.com/rbenv/rbenv/issues).\n\n\n  [ruby-build]: https://github.com/rbenv/ruby-build#readme\n  [hooks]: https://github.com/rbenv/rbenv/wiki/Authoring-plugins#rbenv-hooks\n  [alternatives]: https://github.com/rbenv/rbenv/wiki/Comparison-of-version-managers\n  [plugins]: https://github.com/rbenv/rbenv/wiki/Plugins\n","funding_links":[],"categories":["Shell","List of \\*env-, ch\\*- and \\*vm- style version managers","Developing","Development","开源工具","Tools","Performance Enhancements","其他","Setting up","Ruby Tools","Ruby Tools and Frameworks","bash","Version Managers","Python Frameworks and Tools","Applications","Package manager","🧰 Tools","Ruby","Table of Contents"],"sub_categories":["Testing","Time Series","命令行工具","Interfaces","网络服务_其他","E-Books","Mesh networks","JavaScript Libraries for Machine Learning","Ruby","System tools","Version management","Version Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbenv%2Frbenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frbenv%2Frbenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frbenv%2Frbenv/lists"}