For just a handful of people, rbenv init would hang indefinitely. Turning on
debugging output suggested that the `read` expression to split PATH into a bash
array was hanging, but I could never reproduce this myself. Instead, this uses
bash v4+ `readarray` if it's available, or falls back to bash v3 `read` with the
default DELIM being a newline character. This will cause a regression if any PATH
entries contain a literal newline character, but hopefully people are not relying
on such paths.
The directory /usr/etc is an optional directory and used by
Fedora, RHEL 9, and openSUSE. The purpose of /usr/etc is to store
distribution-provided configuration files that can be overridden
by user-modified files in /etc.
Also used in the sister project pyenv/pyenv#3039
Co-authored-by: Mislav Marohnić <git@mislav.net>
When `rbenv init` is invoked to automatically edit shell startup files,
the generated lines will be invoking `rbenv init - --no-rehash` by default
to help speed up shell startup. Auto-rehashing on every shell startup can
be slow for some users but is not crucial to rbenv operation. Lets assume
that rbenv shims are already healthy and that they will be regenerated as
needed after installing new ruby versions and gems.
When running `rbenv init`, typically during rbenv setup, users expected
their shell environment to be modified permanently. Instead, what the
command would do is print the instructions to the user and expect them
to edit their shell initialization files accordingly. This proved to
be unintuitive.
Now, running `rbenv init <shells>...` will modify the shell initialization
files of the following shells:
- bash: `~/.bash_profile` or `~/.bashrc` if the latter exists but the former does not
- zsh: `~/.zprofile` or `~/.zshrc` if the latter exists and mentions "rbenv"
- fish: `~/.config/fish/config.fish`
If no shells were specified on the command line, rbenv will try to detect
the current shell.
It should be safe to run `rbenv init` multiple times, as the command will
avoid modifying any shell startup file that already mentions "rbenv init".
The new `_rbenv` script will be autoloaded by zsh as long as it's found in $FPATH.
It should be the package manager's responsibility to symlink or move this file
into an appropriate location.
Co-authored-by: Mislav Marohnić <git@mislav.net>
With zsh `setopt warn_create_global` the "shell" command used to cause
a warning message:
scalar parameter RBENV_VERSION_OLD created globally in function rbenv.
By using `typeset -g` specifically for zsh, this warning goes away.
The `rubygems_plugin.rb` file doesn't get loaded until after `Bundler::Installer.install` is called, so target `Bundler::Installer#install` to fix invocation order issues.
Co-authored-by: Mislav Marohnić <git@mislav.net>
Update rbenv-version-file docs to indicate that the returned version file may or may not actually exist.
Co-authored-by: Mislav Marohnić <git@mislav.net>
Korn shell had two major versions: ’88 and ’93. Some systems have ksh
installed under the name `ksh93`. A few systems (maybe only Solaris
now) also have a `ksh88`. A few others use the `pdksh` (roughly ’88)
or `mksh` (roughly ’93) implementations, originated before ksh was
open source.
As far as the (very minor) use in rbenv is concerned, these are all
equivalent. This change accepts all of the above.
Tested with `ksh93`, `pdksh`, and `mksh`.