docs: further clarify the rbenv init command

This commit is contained in:
Mislav Marohnić 2024-12-02 18:16:10 +01:00 committed by GitHub
parent 4aa904634f
commit a43095dc11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -288,7 +288,20 @@ name | default | description
### How rbenv hooks into your shell
`rbenv init` is a helper command to bootstrap rbenv into a shell. This helper is part of the recommended installation instructions, but optional, as an advanced user can set up the following tasks manually. Here is what the command does when its output is `eval`'d by a shell during its startup:
`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:
1. `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.)
2. `rbenv init -`: made for machines, this command outputs a shell script suitable to be eval'd by the user's shell.
When `rbenv init` is invoked from a bash shell, for example, it will add the following to the user's `~/.bashrc` or `~/.bash_profile`:
```sh
# Added by `rbenv init` on <DATE>
eval "$(rbenv init - --no-rehash bash)"
```
You 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:
0. Adds `rbenv` executable to PATH if necessary.
@ -300,7 +313,6 @@ name | default | description
4. 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.
You can run `rbenv init -` for yourself to inspect the generated script.
### Uninstalling rbenv