mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-07 20:31:01 -05:00
6820704c91
When we started to support reading `.ruby-version` files, we made a commitment to not support fuzzy version matching. Treating "ruby-2.1.5" as "2.1.5" is a sort of fuzzy matching, so we put in place a warning telling you to remove the extraneous "ruby-" prefix popularly used by other Ruby version managers to denote MRI. (Their logic is that MRI is "ruby" and other rubies are not "ruby", apparently.) However, people are often not able to remove the prefix in their projects because they want to support other coworkers and tools that sadly still require the prefix, like RubyMine. So to restore sanity for a big portion of our users, the warning is gone.
28 lines
669 B
Bash
Executable file
28 lines
669 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Summary: Show the current Ruby version
|
|
set -e
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
|
|
|
if [ -z "$RBENV_VERSION" ]; then
|
|
RBENV_VERSION_FILE="$(rbenv-version-file)"
|
|
RBENV_VERSION="$(rbenv-version-file-read "$RBENV_VERSION_FILE" || true)"
|
|
fi
|
|
|
|
if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then
|
|
echo "system"
|
|
exit
|
|
fi
|
|
|
|
version_exists() {
|
|
local version="$1"
|
|
[ -d "${RBENV_ROOT}/versions/${version}" ]
|
|
}
|
|
|
|
if version_exists "$RBENV_VERSION"; then
|
|
echo "$RBENV_VERSION"
|
|
elif version_exists "${RBENV_VERSION#ruby-}"; then
|
|
echo "${RBENV_VERSION#ruby-}"
|
|
else
|
|
echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2
|
|
exit 1
|
|
fi
|