pax_global_header00006660000000000000000000000064120716174160014517gustar00rootroot0000000000000052 comment=9375e99f921f428849f19efe2a2e500b3295d1a7 rbenv-0.4.0/000077500000000000000000000000001207161741600126345ustar00rootroot00000000000000rbenv-0.4.0/.gitignore000066400000000000000000000000431207161741600146210ustar00rootroot00000000000000/plugins /shims /version /versions rbenv-0.4.0/LICENSE000066400000000000000000000020421207161741600136370ustar00rootroot00000000000000Copyright (c) 2013 Sam Stephenson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rbenv-0.4.0/README.md000066400000000000000000000500531207161741600141160ustar00rootroot00000000000000# Groom your app’s Ruby environment with rbenv. Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production. Put rbenv to work with [Bundler](http://gembundler.com/) for painless Ruby upgrades and bulletproof deployments. **Powerful in development.** Specify your app's Ruby version once, in a single file. Keep all your teammates on the same page. No headaches running apps on different versions of Ruby. Just Works™ from the command line and with app servers like [Pow](http://pow.cx). Override the Ruby version anytime: just set an environment variable. **Rock-solid in production.** Your application's executables are its interface with ops. With rbenv and [Bundler binstubs](https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs) you'll never again need to `cd` in a cron job or Chef recipe to ensure you've selected the right runtime. The Ruby version dependency lives in one place—your app—so upgrades and rollbacks are atomic, even when you switch versions. **One thing well.** rbenv is concerned solely with switching Ruby versions. It's simple and predictable. A rich plugin ecosystem lets you tailor it to suit your needs. Compile your own Ruby versions, or use the [ruby-build](https://github.com/sstephenson/ruby-build) plugin to automate the process. Specify per-application environment variables with [rbenv-vars](https://github.com/sstephenson/rbenv-vars). See more [plugins on the wiki](https://github.com/sstephenson/rbenv/wiki/Plugins). [**Why choose rbenv over RVM?**](https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F) ## Table of Contents * [How It Works](#how-it-works) * [Understanding PATH](#understanding-path) * [Understanding Shims](#understanding-shims) * [Choosing the Ruby Version](#choosing-the-ruby-version) * [Locating the Ruby Installation](#locating-the-ruby-installation) * [Installation](#installation) * [Basic GitHub Checkout](#basic-github-checkout) * [Upgrading](#upgrading) * [Homebrew on Mac OS X](#homebrew-on-mac-os-x) * [Neckbeard Configuration](#neckbeard-configuration) * [Uninstalling Ruby Versions](#uninstalling-ruby-versions) * [Command Reference](#command-reference) * [rbenv local](#rbenv-local) * [rbenv global](#rbenv-global) * [rbenv shell](#rbenv-shell) * [rbenv versions](#rbenv-versions) * [rbenv version](#rbenv-version) * [rbenv rehash](#rbenv-rehash) * [rbenv which](#rbenv-which) * [rbenv whence](#rbenv-whence) * [Development](#development) * [Version History](#version-history) * [License](#license) ## How It Works At at high level, rbenv intercepts Ruby commands using shim executables injected into your `PATH`, determines which Ruby version has been specified by your application, and passes your commands along to the correct Ruby installation. ### Understanding PATH When you run a command like `ruby` or `rake`, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called `PATH`, with each directory in the list separated by a colon: /usr/local/bin:/usr/bin:/bin Directories in `PATH` are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the `/usr/local/bin` directory will be searched first, then `/usr/bin`, then `/bin`. ### Understanding Shims rbenv works by inserting a directory of _shims_ at the front of your `PATH`: ~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin Through a process called _rehashing_, rbenv maintains shims in that directory to match every Ruby command across every installed version of Ruby—`irb`, `gem`, `rake`, `rails`, `ruby`, and so on. Shims are lightweight executables that simply pass your command along to rbenv. So with rbenv installed, when you run, say, `rake`, your operating system will do the following: * Search your `PATH` for an executable file named `rake` * Find the rbenv shim named `rake` at the beginning of your `PATH` * Run the shim named `rake`, which in turn passes the command along to rbenv ### Choosing the Ruby Version When you execute a shim, rbenv determines which Ruby version to use by reading it from the following sources, in this order: 1. The `RBENV_VERSION` environment variable, if specified. You can use the [`rbenv shell`](#rbenv-shell) command to set this environment variable in your current shell session. 2. The application-specific `.ruby-version` file in the current directory, if present. You can modify the current directory's `.ruby-version` file with the [`rbenv local`](#rbenv-local) command. 3. The first `.ruby-version` file found by searching each parent directory until reaching the root of your filesystem, if any. 4. The global `~/.rbenv/version` file. You can modify this file using the [`rbenv global`](#rbenv-global) command. If the global version file is not present, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path. ### Locating the Ruby Installation Once rbenv has determined which version of Ruby your application has specified, it passes the command along to the corresponding Ruby installation. Each Ruby version is installed into its own directory under `~/.rbenv/versions`. For example, you might have these versions installed: * `~/.rbenv/versions/1.8.7-p371/` * `~/.rbenv/versions/1.9.3-p327/` * `~/.rbenv/versions/jruby-1.7.1/` Version names to rbenv are simply the names of the directories in `~/.rbenv/versions`. ## Installation **Compatibility note**: rbenv is _incompatible_ with RVM. Please make sure to fully uninstall RVM and remove any references to it from your shell initialization files before installing rbenv. If you're on Mac OS X, consider [installing with Homebrew](#homebrew-on-mac-os-x). ### Basic GitHub Checkout This will get you going with the latest version of rbenv and make it easy to fork and contribute any changes back upstream. 1. Check out rbenv into `~/.rbenv`. ~~~ sh $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv ~~~ 2. Add `~/.rbenv/bin` to your `$PATH` for access to the `rbenv` command-line utility. ~~~ sh $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile ~~~ **Ubuntu note**: Modify your `~/.profile` instead of `~/.bash_profile`. **Zsh note**: Modify your `~/.zshrc` file instead of `~/.bash_profile`. 3. Add `rbenv init` to your shell to enable shims and autocompletion. ~~~ sh $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile ~~~ _Same as in previous step, use `~/.profile` on Ubuntu, `~/.zshrc` for zsh._ 4. Restart your shell as a login shell so the path changes take effect. You can now begin using rbenv. ~~~ sh $ exec $SHELL -l ~~~ 5. Install [ruby-build](https://github.com/sstephenson/ruby-build), which provides an `rbenv install` command that simplifies the process of installing new Ruby versions. ~~~ $ rbenv install 1.9.3-p327 ~~~ As an alternative, you can download and compile Ruby yourself into `~/.rbenv/versions/`. 6. Rebuild the shim executables. You should do this any time you install a new Ruby executable (for example, when installing a new Ruby version, or when installing a gem that provides a command). ~~~ $ rbenv rehash ~~~ #### Upgrading If you've installed rbenv manually using git, you can upgrade your installation to the cutting-edge version at any time. ~~~ sh $ cd ~/.rbenv $ git pull ~~~ To use a specific release of rbenv, check out the corresponding tag: ~~~ sh $ cd ~/.rbenv $ git fetch $ git checkout v0.3.0 ~~~ ### Homebrew on Mac OS X You can also install rbenv using the [Homebrew](http://mxcl.github.com/homebrew/) package manager on Mac OS X. ~~~ $ brew update $ brew install rbenv $ brew install ruby-build ~~~ To later update these installs, use `upgrade` instead of `install`. Afterwards you'll still need to add `eval "$(rbenv init -)"` to your profile as stated in the caveats. You'll only ever have to do this once. ### Neckbeard Configuration Skip this section unless you must know what every line in your shell profile is doing. `rbenv init` is the only command that crosses the line of loading extra commands into your shell. Coming from rvm, some of you might be opposed to this idea. Here's what `rbenv init` actually does: 1. Sets up your shims path. This is the only requirement for rbenv to function properly. You can do this by hand by prepending `~/.rbenv/shims` to your `$PATH`. 2. Installs autocompletion. This is entirely optional but pretty useful. Sourcing `~/.rbenv/completions/rbenv.bash` will set that up. There is also a `~/.rbenv/completions/rbenv.zsh` for Zsh users. 3. Rehashes shims. From time to time you'll need to rebuild your shim files. Doing this on init makes sure everything is up to date. You can always run `rbenv rehash` manually. 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. The sh dispatcher doesn't do anything crazy like override `cd` or hack your shell prompt, but if for some reason you need `rbenv` to be a real script rather than a shell function, you can safely skip it. Run `rbenv init -` for yourself to see exactly what happens under the hood. ### Uninstalling Ruby Versions As time goes on, Ruby versions you install will accumulate in your `~/.rbenv/versions` directory. To remove old Ruby versions, simply `rm -rf` the directory of the version you want to remove. You can find the directory of a particular Ruby verison with the `rbenv prefix` command, e.g. `rbenv prefix 1.8.7-p357`. The [ruby-build](https://github.com/sstephenson/ruby-build) plugin provides an `rbenv uninstall` command to automate the removal process. ## Command Reference Like `git`, the `rbenv` command delegates to subcommands based on its first argument. The most common subcommands are: ### rbenv local Sets a local application-specific Ruby version by writing the version name to a `.ruby-version` file in the current directory. This version overrides the global version, and can be overridden itself by setting the `RBENV_VERSION` environment variable or with the `rbenv shell` command. $ rbenv local 1.9.3-p327 When run without a version number, `rbenv local` reports the currently configured local version. You can also unset the local version: $ rbenv local --unset Previous versions of rbenv stored local version specifications in a file named `.rbenv-version`. For backwards compatibility, rbenv will read a local version specified in an `.rbenv-version` file, but a `.ruby-version` file in the same directory will take precedence. ### rbenv global Sets the global version of Ruby to be used in all shells by writing the version name to the `~/.rbenv/version` file. This version can be overridden by an application-specific `.ruby-version` file, or by setting the `RBENV_VERSION` environment variable. $ rbenv global 1.8.7-p352 The special version name `system` tells rbenv to use the system Ruby (detected by searching your `$PATH`). When run without a version number, `rbenv global` reports the currently configured global version. ### rbenv shell Sets a shell-specific Ruby version by setting the `RBENV_VERSION` environment variable in your shell. This version overrides application-specific versions and the global version. $ rbenv shell jruby-1.7.1 When run without a version number, `rbenv shell` reports the current value of `RBENV_VERSION`. You can also unset the shell version: $ rbenv shell --unset Note that you'll need rbenv's shell integration enabled (step 3 of the installation instructions) in order to use this command. If you prefer not to use shell integration, you may simply set the `RBENV_VERSION` variable yourself: $ export RBENV_VERSION=jruby-1.7.1 ### rbenv versions Lists all Ruby versions known to rbenv, and shows an asterisk next to the currently active version. $ rbenv versions 1.8.7-p352 1.9.2-p290 * 1.9.3-p327 (set by /Users/sam/.rbenv/version) jruby-1.7.1 rbx-1.2.4 ree-1.8.7-2011.03 ### rbenv version Displays the currently active Ruby version, along with information on how it was set. $ rbenv version 1.8.7-p352 (set by /Volumes/37signals/basecamp/.ruby-version) ### rbenv rehash Installs shims for all Ruby executables known to rbenv (i.e., `~/.rbenv/versions/*/bin/*`). Run this command after you install a new version of Ruby, or install a gem that provides commands. $ rbenv rehash ### rbenv which Displays the full path to the executable that rbenv will invoke when you run the given command. $ rbenv which irb /Users/sam/.rbenv/versions/1.9.3-p327/bin/irb ### rbenv whence Lists all Ruby versions with the given command installed. $ rbenv whence rackup 1.9.3-p327 jruby-1.7.1 ree-1.8.7-2011.03 ## Development The rbenv source code is [hosted on GitHub](https://github.com/sstephenson/rbenv). It's clean, modular, and easy to understand, even if you're not a shell hacker. Please feel free to submit pull requests and file bugs on the [issue tracker](https://github.com/sstephenson/rbenv/issues). ### Version History **0.4.0** (January 4, 2013) * rbenv now prefers `.ruby-version` files to `.rbenv-version` files for specifying local application-specific versions. The `.ruby-version` file has the same format as `.rbenv-version` but is [compatible with other Ruby version managers](https://gist.github.com/1912050). * Deprecated `ruby-local-exec` and moved its functionality into the standard `ruby` shim. See the [ruby-local-exec wiki page](https://github.com/sstephenson/wiki/ruby-local-exec) for upgrade instructions. * Modified shims to include the full path to rbenv so that they can be invoked without having rbenv's bin directory in the `$PATH`. * Sped up `rbenv init` by avoiding rbenv reinintialization and by using a simpler indexing approach. (Users of [chef-rbenv](https://github.com/fnichol/chef-rbenv) should upgrade to the latest version to fix a [compatibility issue](https://github.com/fnichol/chef-rbenv/pull/26).) * Reworked `rbenv help` so that usage and documentation is stored as a comment in each subcommand, enabling plugin commands to hook into the help system. * Added support for full completion of the command line, not just the first argument. * Updated installation instructions for Zsh and Ubuntu users. * Fixed `rbenv which` and `rbenv prefix` with system Ruby versions. * Changed `rbenv exec` to avoid prepending the system Ruby location to `$PATH` to fix issues running system Ruby commands that invoke other commands. * Changed `rbenv rehash` to ensure it exits with a 0 status code under normal operation, and to ensure outdated shims are removed first when rehashing. * Modified `rbenv rehash` to run `hash -r` afterwards, when shell integration is enabled, to ensure the shell's command cache is cleared. * Removed use of the `+=` operator to support older versions of Bash. * Adjusted non-bare `rbenv versions` output to include `system`, if present. * Improved documentation for installing and uninstalling Ruby versions. * Fixed `rbenv versions` not to display a warning if the currently specified version doesn't exist. * Fixed an instance of local variable leakage in the `rbenv` shell function wrapper. * Changed `rbenv shell` to ensure it exits with a non-zero status on failure. * Added `rbenv --version` for printing the current version of rbenv. * Added `/usr/lib/rbenv/hooks` to the plugin hook search path. * Fixed `rbenv which` to account for path entries with spaces. * Changed `rbenv init` to accept option arguments in any order. **0.3.0** (December 25, 2011) * Added an `rbenv root` command which prints the value of `$RBENV_ROOT`, or the default root directory if it's unset. * Clarified Zsh installation instructions in the readme. * Removed some redundant code in `rbenv rehash`. * Fixed an issue with calling `readlink` for paths with spaces. * Changed Zsh initialization code to install completion hooks only for interactive shells. * Added preliminary support for ksh. * `rbenv rehash` creates or removes shims only when necessary instead of removing and re-creating all shims on each invocation. * Fixed that `RBENV_DIR`, when specified, would be incorrectly expanded to its parent directory. * Removed the deprecated `set-default` and `set-local` commands. * Added a `--no-rehash` option to `rbenv init` for skipping the automatic rehash when opening a new shell. **0.2.1** (October 1, 2011) * Changed the `rbenv` command to ensure that `RBENV_DIR` is always an absolute path. This fixes an issue where Ruby scripts using the `ruby-local-exec` wrapper would go into an infinite loop when invoked with a relative path from the command line. **0.2.0** (September 28, 2011) * Renamed `rbenv set-default` to `rbenv global` and `rbenv set-local` to `rbenv local`. The `set-` commands are deprecated and will be removed in the next major release. * rbenv now uses `greadlink` on Solaris. * Added a `ruby-local-exec` command which can be used in shebangs in place of `#!/usr/bin/env ruby` to properly set the project-specific Ruby version regardless of current working directory. * Fixed an issue with `rbenv rehash` when no binaries are present. * Added support for `rbenv-sh-*` commands, which run inside the current shell instead of in a child process. * Added an `rbenv shell` command for conveniently setting the `$RBENV_VERSION` environment variable. * Added support for storing rbenv versions and shims in directories other than `~/.rbenv` with the `$RBENV_ROOT` environment variable. * Added support for debugging rbenv via `set -x` when the `$RBENV_DEBUG` environment variable is set. * Refactored the autocompletion system so that completions are now built-in to each command and shared between bash and Zsh. * Added support for plugin bundles in `~/.rbenv/plugins` as documented in [issue #102](https://github.com/sstephenson/rbenv/pull/102). * Added `/usr/local/etc/rbenv.d` to the list of directories searched for rbenv hooks. * Added support for an `$RBENV_DIR` environment variable which defaults to the current working directory for specifying where rbenv searches for local version files. **0.1.2** (August 16, 2011) * Fixed rbenv to be more resilient against nonexistent entries in `$PATH`. * Made the `rbenv rehash` command operate atomically. * Modified the `rbenv init` script to automatically run `rbenv rehash` so that shims are recreated whenever a new shell is opened. * Added initial support for Zsh autocompletion. * Removed the dependency on egrep for reading version files. **0.1.1** (August 14, 2011) * Fixed a syntax error in the `rbenv help` command. * Removed `-e` from the shebang in favor of `set -e` at the top of each file for compatibility with operating systems that do not support more than one argument in the shebang. **0.1.0** (August 11, 2011) * Initial public release. ### License (The MIT license) Copyright (c) 2013 Sam Stephenson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rbenv-0.4.0/bin/000077500000000000000000000000001207161741600134045ustar00rootroot00000000000000rbenv-0.4.0/bin/rbenv000077700000000000000000000000001207161741600173232../libexec/rbenvustar00rootroot00000000000000rbenv-0.4.0/bin/ruby-local-exec000077500000000000000000000013241207161741600163250ustar00rootroot00000000000000#!/usr/bin/env bash # # `ruby-local-exec` is a drop-in replacement for the standard Ruby # shebang line: # # #!/usr/bin/env ruby-local-exec # # Use it for scripts inside a project with an `.rbenv-version` # file. When you run the scripts, they'll use the project-specified # Ruby version, regardless of what directory they're run from. Useful # for e.g. running project tasks in cron scripts without needing to # `cd` into the project first. set -e export RBENV_DIR="${1%/*}" [ -n "$RBENV_SILENCE_WARNINGS" ] || { echo "rbenv: \`ruby-local-exec' is deprecated and will be removed in the next release." echo " To upgrade: https://github.com/sstephenson/rbenv/wiki/ruby-local-exec" echo } >&2 exec ruby "$@" rbenv-0.4.0/completions/000077500000000000000000000000001207161741600151705ustar00rootroot00000000000000rbenv-0.4.0/completions/rbenv.bash000066400000000000000000000006261207161741600171470ustar00rootroot00000000000000_rbenv() { COMPREPLY=() local word="${COMP_WORDS[COMP_CWORD]}" if [ "$COMP_CWORD" -eq 1 ]; then COMPREPLY=( $(compgen -W "$(rbenv commands)" -- "$word") ) else local words=("${COMP_WORDS[@]}") unset words[0] unset words[$COMP_CWORD] local completions=$(rbenv completions "${words[@]}") COMPREPLY=( $(compgen -W "$completions" -- "$word") ) fi } complete -F _rbenv rbenv rbenv-0.4.0/completions/rbenv.zsh000066400000000000000000000004541207161741600170350ustar00rootroot00000000000000if [[ ! -o interactive ]]; then return fi compctl -K _rbenv rbenv _rbenv() { local words completions read -cA words if [ "${#words}" -eq 2 ]; then completions="$(rbenv commands)" else completions="$(rbenv completions ${words[2,-1]})" fi reply=("${(ps:\n:)completions}") } rbenv-0.4.0/libexec/000077500000000000000000000000001207161741600142475ustar00rootroot00000000000000rbenv-0.4.0/libexec/rbenv000077500000000000000000000027311207161741600153140ustar00rootroot00000000000000#!/usr/bin/env bash set -e [ -n "$RBENV_DEBUG" ] && set -x resolve_link() { $(type -p greadlink readlink | head -1) "$1" } abs_dirname() { local cwd="$(pwd)" local path="$1" while [ -n "$path" ]; do cd "${path%/*}" local name="${path##*/}" path="$(resolve_link "$name" || true)" done pwd cd "$cwd" } if [ -z "${RBENV_ROOT}" ]; then RBENV_ROOT="${HOME}/.rbenv" else RBENV_ROOT="${RBENV_ROOT%/}" fi export RBENV_ROOT if [ -z "${RBENV_DIR}" ]; then RBENV_DIR="$(pwd)" else cd "$RBENV_DIR" 2>/dev/null || { echo "rbenv: cannot change working directory to \`$RBENV_DIR'" exit 1 } >&2 RBENV_DIR="$(pwd)" cd "$OLDPWD" fi export RBENV_DIR shopt -s nullglob bin_path="$(abs_dirname "$0")" for plugin_bin in "${RBENV_ROOT}/plugins/"*/bin; do bin_path="${bin_path}:${plugin_bin}" done export PATH="${bin_path}:${PATH}" hook_path="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks" for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do hook_path="${hook_path}:${plugin_hook}" done export RBENV_HOOK_PATH="$hook_path" shopt -u nullglob command="$1" case "$command" in "" | "-h" | "--help" ) echo -e "$(rbenv---version)\n$(rbenv-help)" >&2 ;; "-v" ) exec rbenv---version ;; * ) command_path="$(command -v "rbenv-$command" || true)" if [ -z "$command_path" ]; then echo "rbenv: no such command \`$command'" >&2 exit 1 fi shift 1 exec "$command_path" "$@" ;; esac rbenv-0.4.0/libexec/rbenv---version000077500000000000000000000010311207161741600171210ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Display the version of rbenv # # Displays the version number of this rbenv release, including the # current revision from git, if available. # # The format of the git revision is: # -- # where `num_commits` is the number of commits since `version` was # tagged. set -e [ -n "$RBENV_DEBUG" ] && set -x version="0.4.0" cd "$RBENV_ROOT" git_revision="$(git describe --tags HEAD 2>/dev/null || true)" git_revision="${git_revision#v}" echo "rbenv ${git_revision:-$version}" rbenv-0.4.0/libexec/rbenv-commands000077500000000000000000000014201207161741600171050ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List all available rbenv commands # Usage: rbenv commands [--sh|--no-sh] set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --sh echo --no-sh exit fi if [ "$1" = "--sh" ]; then sh=1 shift elif [ "$1" = "--no-sh" ]; then nosh=1 shift fi shopt -s nullglob { for path in ${PATH//:/$'\n'}; do for command in "${path}/rbenv-"*; do command="${command##*rbenv-}" if [ -n "$sh" ]; then if [ ${command:0:3} = "sh-" ]; then echo ${command##sh-} fi elif [ -n "$nosh" ]; then if [ ${command:0:3} != "sh-" ]; then echo ${command##sh-} fi else echo ${command##sh-} fi done done } | sort | uniq rbenv-0.4.0/libexec/rbenv-completions000077500000000000000000000006301207161741600176420ustar00rootroot00000000000000#!/usr/bin/env bash # Usage: rbenv completions [arg1 arg2...] set -e [ -n "$RBENV_DEBUG" ] && set -x COMMAND="$1" if [ -z "$COMMAND" ]; then rbenv-help --usage completions >&2 exit 1 fi COMMAND_PATH="$(command -v "rbenv-$COMMAND" || command -v "rbenv-sh-$COMMAND")" if grep -i "^# provide rbenv completions" "$COMMAND_PATH" >/dev/null; then shift exec "$COMMAND_PATH" --complete "$@" fi rbenv-0.4.0/libexec/rbenv-exec000077500000000000000000000017721207161741600162420ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Run an executable with the selected Ruby version # # Usage: rbenv exec [arg1 arg2...] # # Runs an executable by first preparing PATH so that the selected Ruby # version's `bin' directory is at the front. # # For example, if the currently selected Ruby version is 1.9.3-p327: # rbenv exec bundle install # # is equivalent to: # PATH="$RBENV_ROOT/versions/1.9.3-p327/bin:$PATH" bundle install set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then exec rbenv shims --short fi export RBENV_VERSION="$(rbenv-version-name)" RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage exec >&2 exit 1 fi RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")" RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}" for script in $(rbenv-hooks exec); do source "$script" done shift 1 if [ "$RBENV_VERSION" != "system" ]; then export PATH="${RBENV_BIN_PATH}:${PATH}" fi exec -a "$RBENV_COMMAND" "$RBENV_COMMAND_PATH" "$@" rbenv-0.4.0/libexec/rbenv-global000077500000000000000000000017511207161741600165530ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Set or show the global Ruby version # # Usage: rbenv global # # Sets the global Ruby version. You can override the global version at # any time by setting a directory-specific version with `rbenv local' # or by setting the `RBENV_VERSION' environment variable. # # should be a string matching a Ruby version known to rbenv. # The special version string `system' will use your default system Ruby. # Run `rbenv versions' for a list of available Ruby versions. set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo system exec rbenv-versions --bare fi RBENV_VERSION="$1" RBENV_VERSION_FILE="${RBENV_ROOT}/version" if [ -n "$RBENV_VERSION" ]; then rbenv-version-file-write "$RBENV_VERSION_FILE" "$RBENV_VERSION" else rbenv-version-file-read "$RBENV_VERSION_FILE" || rbenv-version-file-read "${RBENV_ROOT}/global" || rbenv-version-file-read "${RBENV_ROOT}/default" || echo system fi rbenv-0.4.0/libexec/rbenv-help000077500000000000000000000062571207161741600162510ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Display help for a command # # Usage: rbenv help [--usage] COMMAND # # Parses and displays help contents from a command's source file. # # A command is considered documented if it starts with a comment block # that has a `Summary:' or `Usage:' section. Usage instructions can # span multiple lines as long as subsequent lines are indented. # The remainder of the comment block is displayed as extended # documentation. set -e [ -n "$RBENV_DEBUG" ] && set -x command_path() { local command="$1" command -v rbenv-"$command" || command -v rbenv-sh-"$command" || true } extract_initial_comment_block() { sed -ne " /^#/ !{ q } s/^#$/# / /^# / { s/^# // p } " } collect_documentation() { awk ' /^Summary:/ { summary = substr($0, 10) next } /^Usage:/ { reading_usage = 1 usage = usage "\n" $0 next } /^( *$| )/ && reading_usage { usage = usage "\n" $0 next } { reading_usage = 0 help = help "\n" $0 } function escape(str) { gsub(/[`\\$"]/, "\\\\&", str) return str } function trim(str) { gsub(/^\n*/, "", str) gsub(/\n*$/, "", str) return str } END { if (usage || summary) { print "summary=\"" escape(summary) "\"" print "usage=\"" escape(trim(usage)) "\"" print "help=\"" escape(trim(help)) "\"" } } ' } documentation_for() { local filename="$(command_path "$1")" if [ -n "$filename" ]; then extract_initial_comment_block < "$filename" | collect_documentation fi } print_summary() { local command="$1" local summary usage help eval "$(documentation_for "$command")" if [ -n "$summary" ]; then printf " %-9s %s\n" "$command" "$summary" fi } print_summaries() { for command; do print_summary "$command" done } print_help() { local command="$1" local summary usage help eval "$(documentation_for "$command")" [ -n "$help" ] || help="$summary" if [ -n "$usage" -o -n "$summary" ]; then if [ -n "$usage" ]; then echo "$usage" else echo "Usage: rbenv ${command}" fi if [ -n "$help" ]; then echo echo "$help" echo fi else echo "Sorry, this command isn't documented yet." >&2 return 1 fi } print_usage() { local command="$1" local summary usage help eval "$(documentation_for "$command")" [ -z "$usage" ] || echo "$usage" } unset usage if [ "$1" = "--usage" ]; then usage="1" shift fi if [ -z "$1" ] || [ "$1" == "rbenv" ]; then echo "Usage: rbenv []" [ -z "$usage" ] || exit echo echo "Some useful rbenv commands are:" print_summaries commands local global shell install uninstall rehash version versions which whence echo echo "See \`rbenv help ' for information on a specific command." echo "For full documentation, see: https://github.com/sstephenson/rbenv#readme" else command="$1" if [ -n "$(command_path "$command")" ]; then if [ -n "$usage" ]; then print_usage "$command" else print_help "$command" fi else echo "rbenv: no such command \`$command'" >&2 exit 1 fi fi rbenv-0.4.0/libexec/rbenv-hooks000077500000000000000000000015051207161741600164330ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List hook scripts for a given rbenv command # Usage: rbenv hooks set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo exec echo rehash echo which exit fi RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage hooks >&2 exit 1 fi resolve_link() { $(type -p greadlink readlink | head -1) $1 } realpath() { local cwd="$(pwd)" local base="$(basename $1)" local path="$1" while [ -n "$path" ]; do cd "${path%/*}" local name="${path##*/}" path="$(resolve_link "$name" || true)" done echo "$(pwd)/$base" cd "$cwd" } shopt -s nullglob for path in ${RBENV_HOOK_PATH//:/$'\n'}; do for script in $path/"$RBENV_COMMAND"/*.bash; do echo $(realpath $script) done done shopt -u nullglob rbenv-0.4.0/libexec/rbenv-init000077500000000000000000000031321207161741600162510ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Configure the shell environment for rbenv # Usage: eval "$(rbenv init - [--no-rehash] [])" set -e [ -n "$RBENV_DEBUG" ] && set -x print="" no_rehash="" for args in "$@" do if [ "$args" = "-" ]; then print=1 shift fi if [ "$args" = "--no-rehash" ]; then no_rehash=1 shift fi done shell="$1" if [ -z "$shell" ]; then shell="$(basename "$SHELL")" fi resolve_link() { $(type -p greadlink readlink | head -1) $1 } abs_dirname() { local cwd="$(pwd)" local path="$1" while [ -n "$path" ]; do cd "${path%/*}" local name="${path##*/}" path="$(resolve_link "$name" || true)" done pwd cd "$cwd" } root="$(abs_dirname "$0")/.." if [ -z "$print" ]; then case "$shell" in bash ) profile='~/.bash_profile' ;; zsh ) profile='~/.zshrc' ;; ksh ) profile='~/.profile' ;; * ) profile='your profile' ;; esac { echo "# Load rbenv automatically by adding" echo "# the following to ${profile}:" echo echo 'eval "$(rbenv init -)"' echo } >&2 exit 1 fi mkdir -p "${RBENV_ROOT}/"{shims,versions} echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' case "$shell" in bash | zsh ) echo "source \"$root/completions/rbenv.${shell}\"" ;; esac if [ -z "$no_rehash" ]; then echo 'rbenv rehash 2>/dev/null' fi commands=(`rbenv-commands --sh`) IFS="|" cat < # rbenv local --unset # # Sets the local application-specific Ruby version by writing the # version name to a file named `.ruby-version'. # # When you run a Ruby command, rbenv will look for a `.ruby-version' # file in the current directory and each parent directory. If no such # file is found in the tree, rbenv will use the global Ruby version # specified with `rbenv global'. A version specified with the # `RBENV_VERSION' environment variable takes precedence over local # and global versions. # # For backwards compatibility, rbenv will also read version # specifications from `.rbenv-version' files, but a `.ruby-version' # file in the same directory takes precedence. # # should be a string matching a Ruby version known to rbenv. # The special version string `system' will use your default system Ruby. # Run `rbenv versions' for a list of available Ruby versions. set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --unset echo system exec rbenv-versions --bare fi RBENV_VERSION="$1" if [ "$RBENV_VERSION" = "--unset" ]; then rm -f .ruby-version .rbenv-version elif [ -n "$RBENV_VERSION" ]; then if [ "$(RBENV_VERSION= rbenv-version-origin)" -ef .rbenv-version ]; then rm -f .rbenv-version { echo "rbenv: removed existing \`.rbenv-version' file and migrated" echo " local version specification to \`.ruby-version' file" } >&2 fi rbenv-version-file-write .ruby-version "$RBENV_VERSION" else rbenv-version-file-read .ruby-version || rbenv-version-file-read .rbenv-version || { echo "rbenv: no local version configured for this directory" exit 1 } >&2 fi rbenv-0.4.0/libexec/rbenv-prefix000077500000000000000000000015611207161741600166070ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Display prefix for a Ruby version # Usage: rbenv prefix [] # # Displays the directory where a Ruby version is installed. If no # version is given, `rbenv prefix' displays the location of the # currently selected version. set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo system exec rbenv-versions --bare fi if [ -n "$1" ]; then export RBENV_VERSION="$1" elif [ -z "$RBENV_VERSION" ]; then RBENV_VERSION="$(rbenv-version-name)" fi if [ "$RBENV_VERSION" = "system" ]; then RUBY_PATH="$(rbenv-which ruby)" RUBY_PATH="${RUBY_PATH%/*}" echo "${RUBY_PATH%/bin}" exit fi RBENV_PREFIX_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}" if [ ! -d "$RBENV_PREFIX_PATH" ]; then echo "rbenv: version \`${RBENV_VERSION}' not installed" >&2 exit 1 fi echo "$RBENV_PREFIX_PATH" rbenv-0.4.0/libexec/rbenv-rehash000077500000000000000000000101351207161741600165610ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Rehash rbenv shims (run this after installing executables) set -e [ -n "$RBENV_DEBUG" ] && set -x SHIM_PATH="${RBENV_ROOT}/shims" PROTOTYPE_SHIM_PATH="${SHIM_PATH}/.rbenv-shim" # Create the shims directory if it doesn't already exist. mkdir -p "$SHIM_PATH" # Ensure only one instance of rbenv-rehash is running at a time by # setting the shell's `noclobber` option and attempting to write to # the prototype shim file. If the file already exists, print a warning # to stderr and exit with a non-zero status. set -o noclobber { echo > "$PROTOTYPE_SHIM_PATH" } 2>/dev/null || { echo "rbenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists" exit 1 } >&2 set +o noclobber # If we were able to obtain a lock, register a trap to clean up the # prototype shim when the process exits. trap remove_prototype_shim EXIT remove_prototype_shim() { rm -f "$PROTOTYPE_SHIM_PATH" } # The prototype shim file is a script that re-execs itself, passing # its filename and any arguments to `rbenv exec`. This file is # hard-linked for every executable and then removed. The linking # technique is fast, uses less disk space than unique files, and also # serves as a locking mechanism. create_prototype_shim() { cat > "$PROTOTYPE_SHIM_PATH" </dev/null 2>&1; then for shim in *; do rm -f "$shim"; done fi break done } # The basename of each argument passed to `make_shims` will be # registered for installation as a shim. In this way, plugins may call # `make_shims` with a glob to register many shims at once. make_shims() { local shims="$@" for file in $shims; do local shim="${file##*/}" register_shim "$shim" done } # Create an empty array for the list of registered shims and an empty # string to use as a search index. registered_shims=() registered_shims_index="" # We will keep track of shims registered for installation with the # global `reigstered_shims` array and with a global search index # string. The array will let us iterate over all registered shims. The # index string will let us quickly check whether a shim with the given # name has been registered or not. register_shim() { local shim="$@" registered_shims["${#registered_shims[@]}"]="$shim" registered_shims_index="$registered_shims_index/$shim/" } # To install all the registered shims, we iterate over the # `registered_shims` array and create a link if one does not already # exist. install_registered_shims() { local shim for shim in "${registered_shims[@]}"; do [ -e "$shim" ] || ln -f "$PROTOTYPE_SHIM_PATH" "$shim" done } # Once the registered shims have been installed, we make a second pass # over the contents of the shims directory. Any file that is present # in the directory but has not been registered as a shim should be # removed. remove_stale_shims() { local shim for shim in *; do if [[ "$registered_shims_index" != *"/$shim/"* ]]; then rm -f "$shim" fi done } # Change to the shims directory. cd "$SHIM_PATH" shopt -s nullglob # Create the prototype shim, then register shims for all known # executables. create_prototype_shim remove_outdated_shims make_shims ../versions/*/bin/* # Restore the previous working directory. cd "$OLDPWD" # Allow plugins to register shims. for script in $(rbenv-hooks rehash); do source "$script" done # Change back to the shims directory to install the registered shims # and remove stale shims. cd "$SHIM_PATH" install_registered_shims remove_stale_shims rbenv-0.4.0/libexec/rbenv-root000077500000000000000000000001551207161741600162730ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Display the root directory where versions and shims are kept echo $RBENV_ROOT rbenv-0.4.0/libexec/rbenv-sh-rehash000077500000000000000000000004661207161741600171770ustar00rootroot00000000000000#!/usr/bin/env bash set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then exec rbenv-rehash --complete fi # When rbenv shell integration is enabled, delegate to rbenv-rehash, # then tell the shell to empty its command lookup cache. rbenv-rehash echo "hash -r" rbenv-0.4.0/libexec/rbenv-sh-shell000077500000000000000000000022071207161741600170270ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Set or show the shell-specific Ruby version # # Usage: rbenv shell # rbenv shell --unset # # Sets a shell-specific Ruby version by setting the `RBENV_VERSION' # environment variable in your shell. This version overrides local # application-specific versions and the global version. # # should be a string matching a Ruby version known to rbenv. # The special version string `system' will use your default system Ruby. # Run `rbenv versions' for a list of available Ruby versions. set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --unset echo system exec rbenv-versions --bare fi version="$1" if [ -z "$version" ]; then if [ -z "$RBENV_VERSION" ]; then echo "rbenv: no shell-specific version configured" >&2 exit 1 else echo "echo \"\$RBENV_VERSION\"" exit fi fi if [ "$version" = "--unset" ]; then echo "unset RBENV_VERSION" exit fi # Make sure the specified version is installed. if rbenv-prefix "$version" >/dev/null; then echo "export RBENV_VERSION=\"${version}\"" else echo "return 1" exit 1 fi rbenv-0.4.0/libexec/rbenv-shims000077500000000000000000000005511207161741600164330ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List existing rbenv shims # Usage: rbenv shims [--short] set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --short exit fi for command in "${RBENV_ROOT}/shims/"*; do if [ "$1" = "--short" ]; then echo "${command##*/}" else echo "$command" fi done | sort rbenv-0.4.0/libexec/rbenv-version000077500000000000000000000004731207161741600170000ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Show the current Ruby version and its origin # # Shows the currently selected Ruby version and how it was # selected. To obtain only the version string, use `rbenv # version-name'. set -e [ -n "$RBENV_DEBUG" ] && set -x echo "$(rbenv-version-name) (set by $(rbenv-version-origin))" rbenv-0.4.0/libexec/rbenv-version-file000077500000000000000000000014551207161741600177160ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Detect the file that sets the current rbenv version set -e [ -n "$RBENV_DEBUG" ] && set -x find_local_version_file() { local root="$1" while [ -n "$root" ]; do if [ -e "${root}/.ruby-version" ]; then echo "${root}/.ruby-version" exit elif [ -e "${root}/.rbenv-version" ]; then echo "${root}/.rbenv-version" exit fi root="${root%/*}" done } find_local_version_file "$RBENV_DIR" [ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD" global_version_file="${RBENV_ROOT}/version" if [ -e "$global_version_file" ]; then echo "$global_version_file" elif [ -e "${RBENV_ROOT}/global" ]; then echo "${RBENV_ROOT}/global" elif [ -e "${RBENV_ROOT}/default" ]; then echo "${RBENV_ROOT}/default" else echo "$global_version_file" fi rbenv-0.4.0/libexec/rbenv-version-file-read000077500000000000000000000010531207161741600206210ustar00rootroot00000000000000#!/usr/bin/env bash # Usage: rbenv version-file-read set -e [ -n "$RBENV_DEBUG" ] && set -x VERSION_FILE="$1" if [ -e "$VERSION_FILE" ]; then # Read the first non-whitespace word from the specified version file. # Be careful not to load it whole in case there's something crazy in it. version="" while read -a words; do word="${words[0]}" if [ -z "$version" ] && [ -n "$word" ]; then version="$word" fi done < <( cat "$VERSION_FILE" && echo ) if [ -n "$version" ]; then echo "$version" exit fi fi exit 1 rbenv-0.4.0/libexec/rbenv-version-file-write000077500000000000000000000006771207161741600210530ustar00rootroot00000000000000#!/usr/bin/env bash # Usage: rbenv version-file-write set -e [ -n "$RBENV_DEBUG" ] && set -x RBENV_VERSION_FILE="$1" RBENV_VERSION="$2" if [ -z "$RBENV_VERSION" ] || [ -z "$RBENV_VERSION_FILE" ]; then rbenv-help --usage version-file-write >&2 exit 1 fi # Make sure the specified version is installed. rbenv-prefix "$RBENV_VERSION" >/dev/null # Write the version out to disk. echo "$RBENV_VERSION" > "$RBENV_VERSION_FILE" rbenv-0.4.0/libexec/rbenv-version-name000077500000000000000000000014611207161741600177140ustar00rootroot00000000000000#!/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 "warning: ignoring extraneous \`ruby-' prefix in version \`${RBENV_VERSION}'" echo " (set by $(rbenv-version-origin))" } >&2 echo "${RBENV_VERSION#ruby-}" else echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2 exit 1 fi rbenv-0.4.0/libexec/rbenv-version-origin000077500000000000000000000003351207161741600202620ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Explain how the current Ruby version is set set -e [ -n "$RBENV_DEBUG" ] && set -x if [ -n "$RBENV_VERSION" ]; then echo "RBENV_VERSION environment variable" else rbenv-version-file fi rbenv-0.4.0/libexec/rbenv-versions000077500000000000000000000015471207161741600171660ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List all Ruby versions available to rbenv # Usage: rbenv versions [--bare] # # Lists all Ruby versions found in `$RBENV_ROOT/versions/*'. set -e [ -n "$RBENV_DEBUG" ] && set -x if [ "$1" = "--bare" ]; then hit_prefix="" miss_prefix="" current_version="" include_system="" else hit_prefix="* " miss_prefix=" " current_version="$(rbenv-version-name || true)" include_system="1" fi print_version() { if [ "$1" == "$current_version" ]; then echo "${hit_prefix}$(rbenv-version 2>/dev/null)" else echo "${miss_prefix}$1" fi } # Include "system" in the non-bare output, if it exists if [ -n "$include_system" ] && RBENV_VERSION=system rbenv-which ruby >/dev/null 2>&1; then print_version system fi for path in "${RBENV_ROOT}/versions/"*; do if [ -d "$path" ]; then print_version "${path##*/}" fi done rbenv-0.4.0/libexec/rbenv-whence000077500000000000000000000013741207161741600165650ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List all Ruby versions that contain the given executable # Usage: rbenv whence [--path] set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --path exec rbenv shims --short fi if [ "$1" = "--path" ]; then print_paths="1" shift else print_paths="" fi whence() { local command="$1" rbenv-versions --bare | while read version; do path="$(rbenv-prefix "$version")/bin/${command}" if [ -x "$path" ]; then [ "$print_paths" ] && echo "$path" || echo "$version" fi done } RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage whence >&2 exit 1 fi result="$(whence "$RBENV_COMMAND")" [ -n "$result" ] && echo "$result" rbenv-0.4.0/libexec/rbenv-which000077500000000000000000000032031207161741600164070ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Display the full path to an executable # # Usage: rbenv which # # Displays the full path to the executable that rbenv will invoke when # you run the given command. set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then exec rbenv shims --short fi expand_path() { if [ ! -d "$1" ]; then return 1 fi local cwd="$(pwd)" cd "$1" pwd cd "$cwd" } remove_from_path() { local path_to_remove="$(expand_path "$1")" local result="" if [ -z "$path_to_remove" ]; then echo "${PATH}" return fi local paths IFS=: paths=($PATH) for path in "${paths[@]}"; do path="$(expand_path "$path" || true)" if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then result="${result}${path}:" fi done echo "${result%:}" } RBENV_VERSION="$(rbenv-version-name)" RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage which >&2 exit 1 fi if [ "$RBENV_VERSION" = "system" ]; then PATH="$(remove_from_path "${RBENV_ROOT}/shims")" RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND" || true)" else RBENV_COMMAND_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}" fi for script in $(rbenv-hooks which); do source "$script" done if [ -x "$RBENV_COMMAND_PATH" ]; then echo "$RBENV_COMMAND_PATH" else echo "rbenv: $RBENV_COMMAND: command not found" >&2 versions="$(rbenv-whence "$RBENV_COMMAND" || true)" if [ -n "$versions" ]; then { echo echo "The \`$1' command exists in these Ruby versions:" echo "$versions" | sed 's/^/ /g' echo } >&2 fi exit 127 fi