pax_global_header00006660000000000000000000000064131205177450014517gustar00rootroot0000000000000052 comment=6cd487db8138816d9c2898846e9066f21b47a284 rbenv-1.1.1/000077500000000000000000000000001312051774500126335ustar00rootroot00000000000000rbenv-1.1.1/.agignore000066400000000000000000000000231312051774500144220ustar00rootroot00000000000000./versions ./cache rbenv-1.1.1/.gitignore000066400000000000000000000001411312051774500146170ustar00rootroot00000000000000/plugins /shims /version /versions /sources /cache /libexec/*.dylib /src/Makefile /src/*.o /gems rbenv-1.1.1/.travis.yml000066400000000000000000000002701312051774500147430ustar00rootroot00000000000000sudo: false install: git clone --depth 1 https://github.com/sstephenson/bats.git script: PATH="./bats/bin:$PATH" test/run language: c env: - RBENV_NATIVE_EXT= - RBENV_NATIVE_EXT=1 rbenv-1.1.1/.vimrc000066400000000000000000000000431312051774500137510ustar00rootroot00000000000000set wildignore+=versions/*,cache/* rbenv-1.1.1/CONDUCT.md000066400000000000000000000064761312051774500142710ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting one of the project maintainers listed below. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Project Maintainers * Sam Stephenson <> * Mislav Marohnić <> * Erik Michaels-Ober <> ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ rbenv-1.1.1/LICENSE000066400000000000000000000020421312051774500136360ustar00rootroot00000000000000Copyright (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-1.1.1/README.md000066400000000000000000000401651312051774500141200ustar00rootroot00000000000000# 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://bundler.io/) 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/rbenv/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][] plugin to automate the process. Specify per-application environment variables with [rbenv-vars](https://github.com/rbenv/rbenv-vars). See more [plugins on the wiki](https://github.com/rbenv/rbenv/wiki/Plugins). [**Why choose rbenv over RVM?**](https://github.com/rbenv/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) * [How rbenv hooks into your shell](#how-rbenv-hooks-into-your-shell) * [Installing Ruby versions](#installing-ruby-versions) * [Installing Ruby gems](#installing-ruby-gems) * [Uninstalling Ruby versions](#uninstalling-ruby-versions) * [Uninstalling rbenv](#uninstalling-rbenv) * [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) * [Environment variables](#environment-variables) * [Development](#development) ## How It Works At a 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 first `.ruby-version` file found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem. 3. The first `.ruby-version` file found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the `.ruby-version` file in the current working directory with the [`rbenv local`](#rbenv-local) command. 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 https://github.com/rbenv/rbenv.git ~/.rbenv ~~~ Optionally, try to compile dynamic bash extension to speed up rbenv. Don't worry if it fails; rbenv will still work normally: ~~~ $ cd ~/.rbenv && src/configure && make -C src ~~~ 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 Desktop note**: Modify your `~/.bashrc` instead of `~/.bash_profile`. **Zsh note**: Modify your `~/.zshrc` file instead of `~/.bash_profile`. 3. Run `~/.rbenv/bin/rbenv init` for shell-specific instructions on how to initialize rbenv to enable shims and autocompletion. 4. Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if rbenv was set up: ~~~ sh $ type rbenv #=> "rbenv is a function" ~~~ 5. _(Optional)_ Install [ruby-build][], which provides the `rbenv install` command that simplifies the process of [installing new Ruby versions](#installing-ruby-versions). #### 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 ~~~ If you've [installed via Homebrew](#homebrew-on-mac-os-x), then upgrade via its `brew` command: ~~~ sh $ brew update $ brew upgrade rbenv ruby-build ~~~ ### Homebrew on Mac OS X As an alternative to installation via GitHub checkout, you can install rbenv and [ruby-build][] using the [Homebrew](http://brew.sh) package manager on Mac OS X: ~~~ $ brew update $ brew install rbenv $ rbenv init ~~~ You'll only ever have to run `rbenv init` once. ### How rbenv hooks into your shell 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 automatically 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. ### Installing Ruby versions The `rbenv install` command doesn't ship with rbenv out of the box, but is provided by the [ruby-build][] project. If you installed it either as part of GitHub checkout process outlined above or via Homebrew, you should be able to: ~~~ sh # list all available versions: $ rbenv install -l # install a Ruby version: $ rbenv install 2.0.0-p247 ~~~ Alternatively to the `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. rbenv doesn't care; it will simply treat any entry in the `versions/` directory as a separate Ruby version. #### Installing Ruby gems Once you've installed some Ruby versions, you'll want to install gems. First, ensure that the target version for your project is the one you want by checking `rbenv version` (see [Command Reference](#command-reference)). Select another version using `rbenv local 2.0.0-p247`, for example. Then, proceed to install gems as you normally would: ```sh $ gem install bundler ``` **You don't need sudo** to install gems. Typically, the Ruby versions will be installed and writeable by your user. No extra privileges are required to install gems. Check the location where gems are being installed with `gem env`: ```sh $ gem env home # => ~/.rbenv/versions//lib/ruby/gems/... ``` ### 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 version with the `rbenv prefix` command, e.g. `rbenv prefix 1.8.7-p357`. The [ruby-build][] plugin provides an `rbenv uninstall` command to automate the removal process. ### Uninstalling rbenv The simplicity of rbenv makes it easy to temporarily disable it, or uninstall from the system. 1. To **disable** rbenv managing your Ruby versions, simply 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, as before rbenv. `rbenv` will still be accessible on the command line, but your Ruby apps won't be affected by version switching. 2. To completely **uninstall** rbenv, perform step (1) and then remove its root directory. This will **delete all Ruby versions** that were installed under `` `rbenv root`/versions/ `` directory: rm -rf `rbenv root` If you've installed rbenv using a package manager, as a final step perform the rbenv package removal. For instance, for Homebrew: brew uninstall rbenv ## 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 ### 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.9.3-p327 (set by /Users/sam/.rbenv/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 ## Environment variables You can affect how rbenv operates with the following settings: name | default | description -----|---------|------------ `RBENV_VERSION` | | Specifies the Ruby version to be used.
Also see [`rbenv shell`](#rbenv-shell) `RBENV_ROOT` | `~/.rbenv` | Defines the directory under which Ruby versions and shims reside.
Also see `rbenv root` `RBENV_DEBUG` | | Outputs debug information.
Also as: `rbenv --debug ` `RBENV_HOOK_PATH` | [_see wiki_][hooks] | Colon-separated list of paths searched for rbenv hooks. `RBENV_DIR` | `$PWD` | Directory to start searching for `.ruby-version` files. ## Development The rbenv source code is [hosted on GitHub](https://github.com/rbenv/rbenv). It's clean, modular, and easy to understand, even if you're not a shell hacker. Tests are executed using [Bats](https://github.com/sstephenson/bats): $ bats test $ bats test/.bats Please feel free to submit pull requests and file bugs on the [issue tracker](https://github.com/rbenv/rbenv/issues). [ruby-build]: https://github.com/rbenv/ruby-build#readme [hooks]: https://github.com/rbenv/rbenv/wiki/Authoring-plugins#rbenv-hooks rbenv-1.1.1/bin/000077500000000000000000000000001312051774500134035ustar00rootroot00000000000000rbenv-1.1.1/bin/rbenv000077700000000000000000000000001312051774500173222../libexec/rbenvustar00rootroot00000000000000rbenv-1.1.1/completions/000077500000000000000000000000001312051774500151675ustar00rootroot00000000000000rbenv-1.1.1/completions/rbenv.bash000066400000000000000000000006261312051774500171460ustar00rootroot00000000000000_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-1.1.1/completions/rbenv.fish000066400000000000000000000010021312051774500171470ustar00rootroot00000000000000function __fish_rbenv_needs_command set cmd (commandline -opc) if [ (count $cmd) -eq 1 -a $cmd[1] = 'rbenv' ] return 0 end return 1 end function __fish_rbenv_using_command set cmd (commandline -opc) if [ (count $cmd) -gt 1 ] if [ $argv[1] = $cmd[2] ] return 0 end end return 1 end complete -f -c rbenv -n '__fish_rbenv_needs_command' -a '(rbenv commands)' for cmd in (rbenv commands) complete -f -c rbenv -n "__fish_rbenv_using_command $cmd" -a "(rbenv completions $cmd)" end rbenv-1.1.1/completions/rbenv.zsh000066400000000000000000000004541312051774500170340ustar00rootroot00000000000000if [[ ! -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,-2]})" fi reply=("${(ps:\n:)completions}") } rbenv-1.1.1/libexec/000077500000000000000000000000001312051774500142465ustar00rootroot00000000000000rbenv-1.1.1/libexec/rbenv000077500000000000000000000047021312051774500153130ustar00rootroot00000000000000#!/usr/bin/env bash set -e unset CDPATH if [ "$1" = "--debug" ]; then export RBENV_DEBUG=1 shift fi if [ -n "$RBENV_DEBUG" ]; then export PS4='+ [${BASH_SOURCE##*/}:${LINENO}] ' set -x fi abort() { { if [ "$#" -eq 0 ]; then cat - else echo "rbenv: $*" fi } >&2 exit 1 } if enable -f "${BASH_SOURCE%/*}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then abs_dirname() { local path="$(realpath "$1")" echo "${path%/*}" } else [ -z "$RBENV_NATIVE_EXT" ] || abort "failed to load \`realpath' builtin" READLINK=$(type -p greadlink readlink | head -1) [ -n "$READLINK" ] || abort "cannot find readlink - are you missing GNU coreutils?" resolve_link() { $READLINK "$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" } fi 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 || abort "cannot change working directory to \`$RBENV_DIR'" 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 PATH="${plugin_bin}:${PATH}" done export PATH="${bin_path}:${PATH}" RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d" if [ "${bin_path%/*}" != "$RBENV_ROOT" ]; then # Add rbenv's own `rbenv.d` unless rbenv was cloned to RBENV_ROOT RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${bin_path%/*}/rbenv.d" fi RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks" for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do RBENV_HOOK_PATH="${RBENV_HOOK_PATH}:${plugin_hook}" done RBENV_HOOK_PATH="${RBENV_HOOK_PATH#:}" export RBENV_HOOK_PATH shopt -u nullglob command="$1" case "$command" in "" ) { rbenv---version rbenv-help } | abort ;; -v | --version ) exec rbenv---version ;; -h | --help ) exec rbenv-help ;; * ) command_path="$(command -v "rbenv-$command" || true)" [ -n "$command_path" ] || abort "no such command \`$command'" shift 1 if [ "$1" = --help ]; then if [[ "$command" == "sh-"* ]]; then echo "rbenv help \"$command\"" else exec rbenv-help "$command" fi else exec "$command_path" "$@" fi ;; esac rbenv-1.1.1/libexec/rbenv---version000077500000000000000000000011701312051774500171240ustar00rootroot00000000000000#!/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="1.1.1" git_revision="" if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q rbenv; then git_revision="$(git describe --tags HEAD 2>/dev/null || true)" git_revision="${git_revision#v}" fi echo "rbenv ${git_revision:-$version}" rbenv-1.1.1/libexec/rbenv-commands000077500000000000000000000014421312051774500171100ustar00rootroot00000000000000#!/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 IFS=: paths=($PATH) shopt -s nullglob { for path in "${paths[@]}"; 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-1.1.1/libexec/rbenv-completions000077500000000000000000000010621312051774500176410ustar00rootroot00000000000000#!/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 # Provide rbenv completions if [ "$COMMAND" = "--complete" ]; then exec rbenv-commands fi COMMAND_PATH="$(command -v "rbenv-$COMMAND" || command -v "rbenv-sh-$COMMAND")" # --help is provided automatically echo --help if grep -iE "^([#%]|--|//) provide rbenv completions" "$COMMAND_PATH" >/dev/null; then shift exec "$COMMAND_PATH" --complete "$@" fi rbenv-1.1.1/libexec/rbenv-exec000077500000000000000000000021071312051774500162320ustar00rootroot00000000000000#!/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 RBENV_VERSION="$(rbenv-version-name)" RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage exec >&2 exit 1 fi export RBENV_VERSION RBENV_COMMAND_PATH="$(rbenv-which "$RBENV_COMMAND")" RBENV_BIN_PATH="${RBENV_COMMAND_PATH%/*}" OLDIFS="$IFS" IFS=$'\n' scripts=(`rbenv-hooks exec`) IFS="$OLDIFS" for script in "${scripts[@]}"; 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-1.1.1/libexec/rbenv-global000077500000000000000000000015761312051774500165570ustar00rootroot00000000000000#!/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" || echo system fi rbenv-1.1.1/libexec/rbenv-help000077500000000000000000000064471312051774500162510ustar00rootroot00000000000000#!/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 # Provide rbenv completions if [ "$1" = "--complete" ]; then echo --usage exec rbenv-commands fi 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() { $(type -p gawk awk | head -1) ' /^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) { sub(/^\n*/, "", str) sub(/\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/rbenv/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-1.1.1/libexec/rbenv-hooks000077500000000000000000000023221312051774500164300ustar00rootroot00000000000000#!/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 version-name echo version-origin echo which exit fi RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage hooks >&2 exit 1 fi if ! enable -f "${BASH_SOURCE%/*}"/rbenv-realpath.dylib realpath 2>/dev/null; then if [ -n "$RBENV_NATIVE_EXT" ]; then echo "rbenv: failed to load \`realpath' builtin" >&2 exit 1 fi READLINK=$(type -p greadlink readlink | head -1) if [ -z "$READLINK" ]; then echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 exit 1 fi resolve_link() { $READLINK "$1" } realpath() { local cwd="$PWD" local path="$1" local name while [ -n "$path" ]; do name="${path##*/}" [ "$name" = "$path" ] || cd "${path%/*}" path="$(resolve_link "$name" || true)" done echo "${PWD}/$name" cd "$cwd" } fi IFS=: hook_paths=($RBENV_HOOK_PATH) shopt -s nullglob for path in "${hook_paths[@]}"; do for script in "$path/$RBENV_COMMAND"/*.bash; do realpath "$script" done done shopt -u nullglob rbenv-1.1.1/libexec/rbenv-init000077500000000000000000000047011312051774500162530ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Configure the shell environment for rbenv # Usage: eval "$(rbenv init - [--no-rehash] [])" set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then echo - echo --no-rehash echo bash echo fish echo ksh echo zsh exit fi 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="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)" shell="${shell%% *}" shell="${shell##-}" shell="${shell:-$SHELL}" shell="${shell##*/}" fi root="${0%/*}/.." if [ -z "$print" ]; then case "$shell" in bash ) if [ -f "${HOME}/.bashrc" ] && [ ! -f "${HOME}/.bash_profile" ]; then profile='~/.bashrc' else profile='~/.bash_profile' fi ;; zsh ) profile='~/.zshrc' ;; ksh ) profile='~/.profile' ;; fish ) profile='~/.config/fish/config.fish' ;; * ) profile='your profile' ;; esac { echo "# Load rbenv automatically by appending" echo "# the following to ${profile}:" echo case "$shell" in fish ) echo 'status --is-interactive; and source (rbenv init -|psub)' ;; * ) echo 'eval "$(rbenv init -)"' ;; esac echo } >&2 exit 1 fi mkdir -p "${RBENV_ROOT}/"{shims,versions} case "$shell" in fish ) echo "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" echo "set -gx RBENV_SHELL $shell" ;; * ) echo 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' echo "export RBENV_SHELL=$shell" ;; esac completion="${root}/completions/rbenv.${shell}" if [ -r "$completion" ]; then echo "source '$completion'" fi if [ -z "$no_rehash" ]; then echo 'command rbenv rehash 2>/dev/null' fi commands=(`rbenv-commands --sh`) case "$shell" in fish ) 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. # # 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 elif [ -n "$RBENV_VERSION" ]; then rbenv-version-file-write .ruby-version "$RBENV_VERSION" else if version_file="$(rbenv-version-file "$PWD")"; then rbenv-version-file-read "$version_file" else echo "rbenv: no local version configured for this directory" >&2 exit 1 fi fi rbenv-1.1.1/libexec/rbenv-prefix000077500000000000000000000020121312051774500165760ustar00rootroot00000000000000#!/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 if RUBY_PATH="$(rbenv-which ruby 2>/dev/null)"; then RUBY_PATH="${RUBY_PATH%/*}" RBENV_PREFIX_PATH="${RUBY_PATH%/bin}" echo "${RBENV_PREFIX_PATH:-/}" exit else echo "rbenv: system version not found in PATH" >&2 exit 1 fi 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-1.1.1/libexec/rbenv-rehash000077500000000000000000000075341312051774500165710ustar00rootroot00000000000000#!/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 || { if [ -w "$SHIM_PATH" ]; then echo "rbenv: cannot rehash: $PROTOTYPE_SHIM_PATH exists" else echo "rbenv: cannot rehash: $SHIM_PATH isn't writable" fi 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 rm -f "$SHIM_PATH"/* fi break done } # List basenames of executables for every Ruby version list_executable_names() { local version file rbenv-versions --bare --skip-aliases | \ while read version; do for file in "${RBENV_ROOT}/versions/${version}/bin/"*; do echo "${file##*/}" done 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 file shim for file; do shim="${file##*/}" register_shim "$shim" done } registered_shims=" " # Registers the name of a shim to be generated. register_shim() { registered_shims="${registered_shims}${1} " } # Install all the shims registered via `make_shims` or `register_shim` directly. install_registered_shims() { local shim file for shim in $registered_shims; do file="${SHIM_PATH}/${shim}" [ -e "$file" ] || cp "$PROTOTYPE_SHIM_PATH" "$file" 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 "$SHIM_PATH"/*; do if [[ "$registered_shims" != *" ${shim##*/} "* ]]; then rm -f "$shim" fi done } shopt -s nullglob # Create the prototype shim, then register shims for all known # executables. create_prototype_shim remove_outdated_shims make_shims $(list_executable_names | sort -u) # Allow plugins to register shims. OLDIFS="$IFS" IFS=$'\n' scripts=(`rbenv-hooks rehash`) IFS="$OLDIFS" for script in "${scripts[@]}"; do source "$script" done install_registered_shims remove_stale_shims rbenv-1.1.1/libexec/rbenv-root000077500000000000000000000001551312051774500162720ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Display the root directory where versions and shims are kept echo $RBENV_ROOT rbenv-1.1.1/libexec/rbenv-sh-rehash000077500000000000000000000006741312051774500171770ustar00rootroot00000000000000#!/usr/bin/env bash set -e [ -n "$RBENV_DEBUG" ] && set -x # Provide rbenv completions if [ "$1" = "--complete" ]; then exec rbenv-rehash --complete fi shell="$(basename "${RBENV_SHELL:-$SHELL}")" # When rbenv shell integration is enabled, delegate to rbenv-rehash, # then tell the shell to empty its command lookup cache. rbenv-rehash case "$shell" in fish ) # no rehash support ;; * ) echo "hash -r 2>/dev/null || true" ;; esac rbenv-1.1.1/libexec/rbenv-sh-shell000077500000000000000000000054271312051774500170350ustar00rootroot00000000000000#!/usr/bin/env bash # # Summary: Set or show the shell-specific Ruby version # # Usage: rbenv shell # 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. # # When `-` is passed instead of the version string, the previously set # version will be restored. With `--unset`, the `RBENV_VERSION` # environment variable gets unset, restoring the environment to the # state before the first `rbenv shell` call. 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" shell="$(basename "${RBENV_SHELL:-$SHELL}")" 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 case "$shell" in fish ) echo 'set -gu RBENV_VERSION_OLD "$RBENV_VERSION"' echo "set -e RBENV_VERSION" ;; * ) echo 'RBENV_VERSION_OLD="$RBENV_VERSION"' echo "unset RBENV_VERSION" ;; esac exit fi if [ "$version" = "-" ]; then case "$shell" in fish ) cat <&2 false end EOS ;; * ) cat <&2 false fi EOS ;; esac exit fi # Make sure the specified version is installed. if rbenv-prefix "$version" >/dev/null; then if [ "$version" != "$RBENV_VERSION" ]; then case "$shell" in fish ) echo 'set -gu RBENV_VERSION_OLD "$RBENV_VERSION"' echo "set -gx RBENV_VERSION \"$version\"" ;; * ) echo 'RBENV_VERSION_OLD="$RBENV_VERSION"' echo "export RBENV_VERSION=\"$version\"" ;; esac fi else echo "false" exit 1 fi rbenv-1.1.1/libexec/rbenv-shims000077500000000000000000000005741312051774500164370ustar00rootroot00000000000000#!/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 shopt -s nullglob for command in "${RBENV_ROOT}/shims/"*; do if [ "$1" = "--short" ]; then echo "${command##*/}" else echo "$command" fi done | sort rbenv-1.1.1/libexec/rbenv-version000077500000000000000000000004731312051774500167770ustar00rootroot00000000000000#!/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-1.1.1/libexec/rbenv-version-file000077500000000000000000000012221312051774500177050ustar00rootroot00000000000000#!/usr/bin/env bash # Usage: rbenv version-file [] # Summary: Detect the file that sets the current rbenv version set -e [ -n "$RBENV_DEBUG" ] && set -x target_dir="$1" find_local_version_file() { local root="$1" while ! [[ "$root" =~ ^//[^/]*$ ]]; do if [ -e "${root}/.ruby-version" ]; then echo "${root}/.ruby-version" return 0 fi [ -n "$root" ] || break root="${root%/*}" done return 1 } if [ -n "$target_dir" ]; then find_local_version_file "$target_dir" else find_local_version_file "$RBENV_DIR" || { [ "$RBENV_DIR" != "$PWD" ] && find_local_version_file "$PWD" } || echo "${RBENV_ROOT}/version" fi rbenv-1.1.1/libexec/rbenv-version-file-read000077500000000000000000000007161312051774500206250ustar00rootroot00000000000000#!/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. IFS="${IFS}"$'\r' words=( $(cut -b 1-1024 "$VERSION_FILE") ) version="${words[0]}" if [ -n "$version" ]; then echo "$version" exit fi fi exit 1 rbenv-1.1.1/libexec/rbenv-version-file-write000077500000000000000000000006771312051774500210520ustar00rootroot00000000000000#!/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-1.1.1/libexec/rbenv-version-name000077500000000000000000000015041312051774500177110ustar00rootroot00000000000000#!/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 OLDIFS="$IFS" IFS=$'\n' scripts=(`rbenv-hooks version-name`) IFS="$OLDIFS" for script in "${scripts[@]}"; do source "$script" done 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 (set by $(rbenv-version-origin))" >&2 exit 1 fi rbenv-1.1.1/libexec/rbenv-version-origin000077500000000000000000000007121312051774500202600ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: Explain how the current Ruby version is set set -e [ -n "$RBENV_DEBUG" ] && set -x unset RBENV_VERSION_ORIGIN OLDIFS="$IFS" IFS=$'\n' scripts=(`rbenv-hooks version-origin`) IFS="$OLDIFS" for script in "${scripts[@]}"; do source "$script" done if [ -n "$RBENV_VERSION_ORIGIN" ]; then echo "$RBENV_VERSION_ORIGIN" elif [ -n "$RBENV_VERSION" ]; then echo "RBENV_VERSION environment variable" else rbenv-version-file fi rbenv-1.1.1/libexec/rbenv-versions000077500000000000000000000044371312051774500171660ustar00rootroot00000000000000#!/usr/bin/env bash # Summary: List all Ruby versions available to rbenv # Usage: rbenv versions [--bare] [--skip-aliases] # # Lists all Ruby versions found in `$RBENV_ROOT/versions/*'. set -e [ -n "$RBENV_DEBUG" ] && set -x unset bare unset skip_aliases # Provide rbenv completions for arg; do case "$arg" in --complete ) echo --bare echo --skip-aliases exit ;; --bare ) bare=1 ;; --skip-aliases ) skip_aliases=1 ;; * ) rbenv-help --usage versions >&2 exit 1 ;; esac done versions_dir="${RBENV_ROOT}/versions" if ! enable -f "${BASH_SOURCE%/*}"/rbenv-realpath.dylib realpath 2>/dev/null; then if [ -n "$RBENV_NATIVE_EXT" ]; then echo "rbenv: failed to load \`realpath' builtin" >&2 exit 1 fi READLINK=$(type -p greadlink readlink | head -1) if [ -z "$READLINK" ]; then echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 exit 1 fi resolve_link() { $READLINK "$1" } realpath() { local cwd="$PWD" local path="$1" local name while [ -n "$path" ]; do name="${path##*/}" [ "$name" = "$path" ] || cd "${path%/*}" path="$(resolve_link "$name" || true)" done echo "${PWD}/$name" cd "$cwd" } fi if [ -d "$versions_dir" ]; then versions_dir="$(realpath "$versions_dir")" fi if [ -n "$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 num_versions=0 print_version() { if [ "$1" == "$current_version" ]; then echo "${hit_prefix}$(rbenv-version 2>/dev/null)" else echo "${miss_prefix}$1" fi num_versions=$((num_versions + 1)) } # 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 shopt -s nullglob for path in "$versions_dir"/*; do if [ -d "$path" ]; then if [ -n "$skip_aliases" ] && [ -L "$path" ]; then target="$(realpath "$path")" [ "${target%/*}" != "$versions_dir" ] || continue fi print_version "${path##*/}" fi done shopt -u nullglob if [ "$num_versions" -eq 0 ] && [ -n "$include_system" ]; then echo "Warning: no Ruby detected on the system" >&2 exit 1 fi rbenv-1.1.1/libexec/rbenv-whence000077500000000000000000000013741312051774500165640ustar00rootroot00000000000000#!/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-1.1.1/libexec/rbenv-which000077500000000000000000000032561312051774500164160ustar00rootroot00000000000000#!/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 remove_from_path() { local path_to_remove="$1" local path_before local result=":${PATH//\~/$HOME}:" while [ "$path_before" != "$result" ]; do path_before="$result" result="${result//:$path_to_remove:/:}" done result="${result%:}" echo "${result#:}" } RBENV_COMMAND="$1" if [ -z "$RBENV_COMMAND" ]; then rbenv-help --usage which >&2 exit 1 fi RBENV_VERSION="${RBENV_VERSION:-$(rbenv-version-name)}" 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 OLDIFS="$IFS" IFS=$'\n' scripts=(`rbenv-hooks which`) IFS="$OLDIFS" for script in "${scripts[@]}"; do source "$script" done if [ -x "$RBENV_COMMAND_PATH" ]; then echo "$RBENV_COMMAND_PATH" elif [ "$RBENV_VERSION" != "system" ] && [ ! -d "${RBENV_ROOT}/versions/${RBENV_VERSION}" ]; then echo "rbenv: version \`$RBENV_VERSION' is not installed (set by $(rbenv-version-origin))" >&2 exit 1 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 rbenv-1.1.1/rbenv.d/000077500000000000000000000000001312051774500141715ustar00rootroot00000000000000rbenv-1.1.1/rbenv.d/exec/000077500000000000000000000000001312051774500151155ustar00rootroot00000000000000rbenv-1.1.1/rbenv.d/exec/gem-rehash.bash000066400000000000000000000000571312051774500177760ustar00rootroot00000000000000export RUBYLIB="${BASH_SOURCE%.bash}:$RUBYLIB" rbenv-1.1.1/rbenv.d/exec/gem-rehash/000077500000000000000000000000001312051774500171355ustar00rootroot00000000000000rbenv-1.1.1/rbenv.d/exec/gem-rehash/rubygems_plugin.rb000066400000000000000000000026231312051774500227000ustar00rootroot00000000000000hook = lambda do |installer| begin # Ignore gems that aren't installed in locations that rbenv searches for binstubs if installer.spec.executables.any? && [Gem.default_bindir, Gem.bindir(Gem.user_dir)].include?(installer.bin_dir) `rbenv rehash` end rescue warn "rbenv: error in gem-rehash (#{$!.class.name}: #{$!.message})" end end if defined?(Bundler::Installer) && Bundler::Installer.respond_to?(:install) && !Bundler::Installer.respond_to?(:install_without_rbenv_rehash) Bundler::Installer.class_eval do class << self alias install_without_rbenv_rehash install def install(root, definition, options = {}) begin if Gem.default_path.include?(Bundler.bundle_path.to_s) bin_dir = Gem.bindir(Bundler.bundle_path.to_s) bins_before = File.exist?(bin_dir) ? Dir.entries(bin_dir).size : 2 end rescue warn "rbenv: error in Bundler post-install hook (#{$!.class.name}: #{$!.message})" end result = install_without_rbenv_rehash(root, definition, options) if bin_dir && File.exist?(bin_dir) && Dir.entries(bin_dir).size > bins_before `rbenv rehash` end result end end end else begin Gem.post_install(&hook) Gem.post_uninstall(&hook) rescue warn "rbenv: error installing gem-rehash hooks (#{$!.class.name}: #{$!.message})" end end rbenv-1.1.1/src/000077500000000000000000000000001312051774500134225ustar00rootroot00000000000000rbenv-1.1.1/src/Makefile.in000066400000000000000000000011001312051774500154570ustar00rootroot00000000000000CC = @CC@ CFLAGS = @CFLAGS@ LOCAL_CFLAGS = @LOCAL_CFLAGS@ DEFS = @DEFS@ LOCAL_DEFS = @LOCAL_DEFS@ CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) $(CFLAGS) SHOBJ_CC = @SHOBJ_CC@ SHOBJ_CFLAGS = @SHOBJ_CFLAGS@ SHOBJ_LD = @SHOBJ_LD@ SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@ SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@ SHOBJ_LIBS = @SHOBJ_LIBS@ SHOBJ_STATUS = @SHOBJ_STATUS@ .c.o: $(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CCFLAGS) -c -o $@ $< ../libexec/rbenv-realpath.dylib: realpath.o $(SHOBJ_LD) $(SHOBJ_LDFLAGS) $(SHOBJ_XLDFLAGS) -o $@ realpath.o $(SHOBJ_LIBS) clean: rm -f *.o ../libexec/*.dylib rbenv-1.1.1/src/bash.h000066400000000000000000000007601312051774500145130ustar00rootroot00000000000000#ifndef __BASH_H__ #define __BASH_H__ #define EXECUTION_SUCCESS 0 #define EXECUTION_FAILURE 1 #define EX_USAGE 258 #define BUILTIN_ENABLED 1 typedef struct word_desc { char *word; int flags; } WORD_DESC; typedef struct word_list { struct word_list *next; WORD_DESC *word; } WORD_LIST; typedef int sh_builtin_func_t(WORD_LIST *); struct builtin { char *name; sh_builtin_func_t *function; int flags; char * const *long_doc; const char *short_doc; char *unused; }; #endif rbenv-1.1.1/src/configure000077500000000000000000000017101312051774500153300ustar00rootroot00000000000000#!/usr/bin/env bash set -e src_dir="${0%/*}" if [ -z "$CC" ]; then if type -p gcc >/dev/null; then CC=gcc else echo "warning: gcc not found; using CC=cc" >&2 CC=cc fi fi if ! type -p "$CC" >/dev/null; then echo "aborted: compiler not found: $CC" >&2 exit 1 fi case "$(uname -s)" in Darwin* ) host_os="darwin$(uname -r)" ;; FreeBSD* ) host_os="freebsd$(uname -r)" ;; OpenBSD* ) host_os="openbsd$(uname -r)" ;; * ) host_os="linux-gnu" esac eval "$("$src_dir"/shobj-conf -C "$CC" -o "$host_os")" sed " s,@CC@,${CC}, s,@CFLAGS@,${CFLAGS}, s,@LOCAL_CFLAGS@,${LOCAL_CFLAGS}, s,@DEFS@,${DEFS}, s,@LOCAL_DEFS@,${LOCAL_DEFS}, s,@SHOBJ_CC@,${SHOBJ_CC}, s,@SHOBJ_CFLAGS@,${SHOBJ_CFLAGS}, s,@SHOBJ_LD@,${SHOBJ_LD}, s,@SHOBJ_LDFLAGS@,${SHOBJ_LDFLAGS//,/\\,}, s,@SHOBJ_XLDFLAGS@,${SHOBJ_XLDFLAGS//,/\\,}, s,@SHOBJ_LIBS@,${SHOBJ_LIBS}, s,@SHOBJ_STATUS@,${SHOBJ_STATUS}, " "$src_dir"/Makefile.in > "$src_dir"/Makefile rbenv-1.1.1/src/realpath.c000066400000000000000000000015001312051774500153620ustar00rootroot00000000000000#include "bash.h" #include #include int realpath_builtin(list) WORD_LIST *list; { int es; char *realbuf, *p; if (list == 0) { // builtin_usage(); return (EX_USAGE); } for (es = EXECUTION_SUCCESS; list; list = list->next) { p = list->word->word; realbuf = realpath(p, NULL); if (realbuf == NULL) { es = EXECUTION_FAILURE; // builtin_error("%s: cannot resolve: %s", p, strerror(errno)); } else { printf("%s\n", realbuf); free(realbuf); } } return es; } char *realpath_doc[] = { "Display each PATHNAME argument, resolving symbolic links. The exit status", "is 0 if each PATHNAME was resolved; non-zero otherwise.", (char *)NULL }; struct builtin realpath_struct = { "realpath", realpath_builtin, BUILTIN_ENABLED, realpath_doc, "realpath pathname [pathname...]", 0 }; rbenv-1.1.1/src/shobj-conf000077500000000000000000000345501312051774500154070ustar00rootroot00000000000000#! /bin/sh # # shobj-conf -- output a series of variable assignments to be substituted # into a Makefile by configure which specify system-dependent # information for creating shared objects that may be loaded # into bash with `enable -f' # # usage: shobj-conf [-C compiler] -c host_cpu -o host_os -v host_vendor # # Chet Ramey # chet@po.cwru.edu # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is part of GNU Bash, the Bourne Again SHell. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # defaults # SHOBJ_STATUS=supported SHLIB_STATUS=supported SHOBJ_CC=cc SHOBJ_CFLAGS= SHOBJ_LD= SHOBJ_LDFLAGS= SHOBJ_XLDFLAGS= SHOBJ_LIBS= SHLIB_XLDFLAGS= SHLIB_LIBS= SHLIB_DOT='.' SHLIB_LIBPREF='lib' SHLIB_LIBSUFF='so' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF)' SHLIB_DLLVERSION='$(SHLIB_MAJOR)' PROGNAME=`basename $0` USAGE="$PROGNAME [-C compiler] -c host_cpu -o host_os -v host_vendor" while [ $# -gt 0 ]; do case "$1" in -C) shift; SHOBJ_CC="$1"; shift ;; -c) shift; host_cpu="$1"; shift ;; -o) shift; host_os="$1"; shift ;; -v) shift; host_vendor="$1"; shift ;; *) echo "$USAGE" >&2 ; exit 2;; esac done case "${host_os}-${SHOBJ_CC}-${host_vendor}" in nsk-cc-tandem) SHOBJ_CFLAGS=-Wglobalized case `uname -m` in NSR*) SHOBJ_CFLAGS="${SHOBJ_CFLAGS} -Wcall_shared" # default on TNS/E, needed on TNS/R SHOBJ_LD=/usr/bin/ld # for TNS/R ;; NSE*|NEO*) SHOBJ_LD=/usr/bin/eld ;; esac SHOBJ_LDFLAGS='-shared -bglobalized -unres_symbols ignore' ;; sunos4*-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD=/usr/bin/ld SHOBJ_LDFLAGS='-assert pure-text' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; sunos4*) SHOBJ_CFLAGS=-pic SHOBJ_LD=/usr/bin/ld SHOBJ_LDFLAGS='-assert pure-text' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; sunos5*-*gcc*|solaris2*-*gcc*) SHOBJ_LD='${CC}' ld_used=`gcc -print-prog-name=ld` if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then # This line works for the GNU ld SHOBJ_LDFLAGS='-shared -Wl,-h,$@' # http://sourceware.org/ml/binutils/2001-08/msg00361.html SHOBJ_CFLAGS=-fPIC else # This line works for the Solaris linker in /usr/ccs/bin/ld SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@' SHOBJ_CFLAGS=-fpic fi # SHLIB_XLDFLAGS='-R $(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sunos5*|solaris2*) SHOBJ_CFLAGS='-K pic' SHOBJ_LD=/usr/ccs/bin/ld SHOBJ_LDFLAGS='-G -dy -z text -i -h $@' # SHLIB_XLDFLAGS='-R $(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; # All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd. linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; freebsd2*) SHOBJ_CFLAGS=-fpic SHOBJ_LD=ld SHOBJ_LDFLAGS='-x -Bshareable' SHLIB_XLDFLAGS='-R$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; # FreeBSD-3.x ELF freebsd3*|freebsdaout*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' else SHOBJ_LDFLAGS='-shared' SHLIB_XLDFLAGS='-R$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' fi ;; # FreeBSD-4.x and later have only ELF freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; # Darwin/MacOS X darwin*) # Common definitions for all darwin/mac os x versions SHOBJ_CFLAGS='-fno-common' SHOBJ_LD='${CC}' SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)' SHLIB_LIBSUFF='dylib' # unused at this time SHLIB_SONAME='$(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF)' case "${host_os}" in # Darwin versions 1, 5, 6, 7 correspond to Mac OS X 10.0, 10.1, 10.2, # and 10.3, respectively. darwin[1-7].*) SHOBJ_STATUS=unsupported SHOBJ_LDFLAGS='-dynamic' SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' ;; # Darwin 8 == Mac OS X 10.4; Mac OS X 10.N == Darwin N+4 *) case "${host_os}" in darwin[89]*|darwin1[012]*) SHOBJ_ARCHFLAGS='-arch_only `/usr/bin/arch`' ;; *) # Mac OS X 10.9 (Mavericks) and later SHOBJ_ARCHFLAGS= # for 32 and 64bit universal library #SHOBJ_ARCHFLAGS='-arch i386 -arch x86_64' #SHOBJ_CFLAGS=${SHOBJ_CFLAGS}' -arch i386 -arch x86_64' ;; esac SHOBJ_LDFLAGS="-dynamiclib -dynamic -undefined dynamic_lookup ${SHOBJ_ARCHFLAGS}" SHLIB_XLDFLAGS="-dynamiclib ${SHOBJ_ARCHFLAGS}"' -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' ;; esac SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1 ;; openbsd*|netbsd*|mirbsd*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_XLDFLAGS='-R$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; bsdi2*) SHOBJ_CC=shlicc2 SHOBJ_CFLAGS= SHOBJ_LD=ld SHOBJ_LDFLAGS=-r SHOBJ_LIBS=-lc_s.2.1.0 # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in # the ass -- they require changing {/usr/lib,etc}/shlib.map on # each system, and the library creation process is byzantine SHLIB_STATUS=unsupported ;; bsdi3*) SHOBJ_CC=shlicc2 SHOBJ_CFLAGS= SHOBJ_LD=ld SHOBJ_LDFLAGS=-r SHOBJ_LIBS=-lc_s.3.0.0 # BSD/OS 2.x and 3.x `shared libraries' are too much of a pain in # the ass -- they require changing {/usr/lib,etc}/shlib.map on # each system, and the library creation process is byzantine SHLIB_STATUS=unsupported ;; bsdi4*) # BSD/OS 4.x now supports ELF and SunOS-style dynamically-linked # shared libraries. gcc 2.x is the standard compiler, and the # `normal' gcc options should work as they do in Linux. SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; osf*-*gcc*) # Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-rpath $(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; osf*) SHOBJ_LD=ld SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"' SHLIB_XLDFLAGS='-rpath $(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com SHOBJ_CFLAGS=-fpic SHOBJ_LD='ld' SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall' SHOBJ_XLDFLAGS='-G' SHLIB_XLDFLAGS='-bM:SRE' SHLIB_LIBS='-lcurses -lc' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; aix4.[2-9]*|aix[5-9].*) SHOBJ_CFLAGS=-K SHOBJ_LD='ld' SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall' SHOBJ_XLDFLAGS='-G' SHLIB_XLDFLAGS='-bM:SRE' SHLIB_LIBS='-lcurses -lc' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; # # THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface # irix[56]*-*gcc*) SHOBJ_CFLAGS='-fpic' SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; irix[56]*) SHOBJ_CFLAGS='-K PIC' SHOBJ_LD=ld # SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@' # Change from David Kaelbling . If you have problems, # remove the `-no_unresolved' SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@' SHLIB_XLDFLAGS='-rpath $(libdir)' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux9*-*gcc*) # must use gcc; the bundled cc cannot compile PIC code SHOBJ_CFLAGS='-fpic' SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s' SHLIB_XLDFLAGS='-Wl,+b,$(libdir)' SHLIB_LIBSUFF='sl' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux9*) SHOBJ_STATUS=unsupported SHLIB_STATUS=unsupported # If you are using the HP ANSI C compiler, you can uncomment and use # this code (I have not tested it) # SHOBJ_STATUS=supported # SHLIB_STATUS=supported # # SHOBJ_CFLAGS='+z' # SHOBJ_LD='ld' # SHOBJ_LDFLAGS='-b +s' # # SHLIB_XLDFLAGS='+b $(libdir)' # SHLIB_LIBSUFF='sl' # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux10*-*gcc*) # must use gcc; the bundled cc cannot compile PIC code SHOBJ_CFLAGS='-fpic' SHOBJ_LD='${CC}' # if you have problems linking here, moving the `-Wl,+h,$@' from # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s' SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)' SHLIB_LIBSUFF='sl' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux10*) SHOBJ_STATUS=unsupported SHLIB_STATUS=unsupported # If you are using the HP ANSI C compiler, you can uncomment and use # this code (I have not tested it) # SHOBJ_STATUS=supported # SHLIB_STATUS=supported # # SHOBJ_CFLAGS='+z' # SHOBJ_LD='ld' # SHOBJ_LDFLAGS='-b +s +h $@' # # SHLIB_XLDFLAGS='+b $(libdir)' # SHLIB_LIBSUFF='sl' # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux11*-*gcc*) # must use gcc; the bundled cc cannot compile PIC code SHOBJ_CFLAGS='-fpic' SHOBJ_LD='${CC}' # SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@' SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@' SHLIB_XLDFLAGS='-Wl,+b,$(libdir)' SHLIB_LIBSUFF='sl' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; hpux11*) SHOBJ_STATUS=unsupported SHLIB_STATUS=unsupported # If you are using the HP ANSI C compiler, you can uncomment and use # this code (I have not tested it) # SHOBJ_STATUS=supported # SHLIB_STATUS=supported # # SHOBJ_CFLAGS='+z' # SHOBJ_LD='ld' # SHOBJ_LDFLAGS='-b +s +h $@' # # SHLIB_XLDFLAGS='+b $(libdir)' # SHLIB_LIBSUFF='sl' # SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv4*-*gcc*) SHOBJ_CFLAGS=-shared SHOBJ_LDFLAGS='-shared -h $@' SHOBJ_LD='${CC}' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv4*) SHOBJ_CFLAGS='-K PIC' SHOBJ_LD=ld SHOBJ_LDFLAGS='-dy -z text -G -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sco3.2v5*-*gcc*) SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sco3.2v5*) SHOBJ_CFLAGS='-K pic -b elf' SHOBJ_LD=ld SHOBJ_LDFLAGS='-G -b elf -dy -z text -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5uw7*-*gcc*) SHOBJ_CFLAGS='-fpic' SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5uw7*) SHOBJ_CFLAGS='-K PIC' SHOBJ_LD=ld SHOBJ_LDFLAGS='-G -dy -z text -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5UnixWare*-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5UnixWare*) SHOBJ_CFLAGS='-K PIC' SHOBJ_LD=ld SHOBJ_LDFLAGS='-G -dy -z text -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5OpenUNIX*-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; sysv5OpenUNIX*) SHOBJ_CFLAGS='-K PIC' SHOBJ_LD=ld SHOBJ_LDFLAGS='-G -dy -z text -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; dgux*-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; dgux*) SHOBJ_CFLAGS='-K pic' SHOBJ_LD=ld SHOBJ_LDFLAGS='-G -dy -h $@' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; msdos*) SHOBJ_STATUS=unsupported SHLIB_STATUS=unsupported ;; cygwin*) SHOBJ_LD='$(CC)' SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' SHLIB_LIBPREF='cyg' SHLIB_LIBSUFF='dll' SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' SHLIB_LIBS='$(TERMCAP_LIB)' SHLIB_DOT= # For official cygwin releases, DLLVERSION will be defined in the # environment of configure, and will be incremented any time the API # changes in a non-backwards compatible manner. Otherwise, it is just # SHLIB_MAJOR. if [ -n "$DLLVERSION" ] ; then SHLIB_DLLVERSION="$DLLVERSION" fi ;; mingw*) SHOBJ_LD='$(CC)' SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' SHLIB_LIBSUFF='dll' SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' SHLIB_LIBS='$(TERMCAP_LIB)' SHLIB_DOT= # For official cygwin releases, DLLVERSION will be defined in the # environment of configure, and will be incremented any time the API # changes in a non-backwards compatible manner. Otherwise, it is just # SHLIB_MAJOR. if [ -n "$DLLVERSION" ] ; then SHLIB_DLLVERSION="$DLLVERSION" fi ;; # # Rely on correct gcc configuration for everything else # *-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; *) SHOBJ_STATUS=unsupported SHLIB_STATUS=unsupported ;; esac echo SHOBJ_CC=\'"$SHOBJ_CC"\' echo SHOBJ_CFLAGS=\'"$SHOBJ_CFLAGS"\' echo SHOBJ_LD=\'"$SHOBJ_LD"\' echo SHOBJ_LDFLAGS=\'"$SHOBJ_LDFLAGS"\' echo SHOBJ_XLDFLAGS=\'"$SHOBJ_XLDFLAGS"\' echo SHOBJ_LIBS=\'"$SHOBJ_LIBS"\' echo SHLIB_XLDFLAGS=\'"$SHLIB_XLDFLAGS"\' echo SHLIB_LIBS=\'"$SHLIB_LIBS"\' echo SHLIB_DOT=\'"$SHLIB_DOT"\' echo SHLIB_LIBPREF=\'"$SHLIB_LIBPREF"\' echo SHLIB_LIBSUFF=\'"$SHLIB_LIBSUFF"\' echo SHLIB_LIBVERSION=\'"$SHLIB_LIBVERSION"\' echo SHLIB_DLLVERSION=\'"$SHLIB_DLLVERSION"\' echo SHOBJ_STATUS=\'"$SHOBJ_STATUS"\' echo SHLIB_STATUS=\'"$SHLIB_STATUS"\' exit 0 rbenv-1.1.1/test/000077500000000000000000000000001312051774500136125ustar00rootroot00000000000000rbenv-1.1.1/test/--version.bats000066400000000000000000000021251312051774500163040ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper export GIT_DIR="${RBENV_TEST_DIR}/.git" setup() { mkdir -p "$HOME" git config --global user.name "Tester" git config --global user.email "tester@test.local" cd "$RBENV_TEST_DIR" } git_commit() { git commit --quiet --allow-empty -m "empty" } @test "default version" { assert [ ! -e "$RBENV_ROOT" ] run rbenv---version assert_success [[ $output == "rbenv "?.?.? ]] } @test "doesn't read version from non-rbenv repo" { git init git remote add origin https://github.com/homebrew/homebrew.git git_commit git tag v1.0 run rbenv---version assert_success [[ $output == "rbenv "?.?.? ]] } @test "reads version from git repo" { git init git remote add origin https://github.com/rbenv/rbenv.git git_commit git tag v0.4.1 git_commit git_commit run rbenv---version assert_success "rbenv 0.4.1-2-g$(git rev-parse --short HEAD)" } @test "prints default version if no tags in git repo" { git init git remote add origin https://github.com/rbenv/rbenv.git git_commit run rbenv---version [[ $output == "rbenv "?.?.? ]] } rbenv-1.1.1/test/commands.bats000066400000000000000000000012651312051774500162720ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper @test "commands" { run rbenv-commands assert_success assert_line "init" assert_line "rehash" assert_line "shell" refute_line "sh-shell" assert_line "echo" } @test "commands --sh" { run rbenv-commands --sh assert_success refute_line "init" assert_line "shell" } @test "commands in path with spaces" { path="${RBENV_TEST_DIR}/my commands" cmd="${path}/rbenv-sh-hello" mkdir -p "$path" touch "$cmd" chmod +x "$cmd" PATH="${path}:$PATH" run rbenv-commands --sh assert_success assert_line "hello" } @test "commands --no-sh" { run rbenv-commands --no-sh assert_success assert_line "init" refute_line "shell" } rbenv-1.1.1/test/completions.bats000066400000000000000000000015601312051774500170230ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper create_command() { bin="${RBENV_TEST_DIR}/bin" mkdir -p "$bin" echo "$2" > "${bin}/$1" chmod +x "${bin}/$1" } @test "command with no completion support" { create_command "rbenv-hello" "#!$BASH echo hello" run rbenv-completions hello assert_success "--help" } @test "command with completion support" { create_command "rbenv-hello" "#!$BASH # Provide rbenv completions if [[ \$1 = --complete ]]; then echo hello else exit 1 fi" run rbenv-completions hello assert_success assert_output < "${bin}/$name" chmod +x "${bin}/$name" } @test "fails with invalid version" { export RBENV_VERSION="2.0" run rbenv-exec ruby -v assert_failure "rbenv: version \`2.0' is not installed (set by RBENV_VERSION environment variable)" } @test "fails with invalid version set from file" { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" echo 1.9 > .ruby-version run rbenv-exec rspec assert_failure "rbenv: version \`1.9' is not installed (set by $PWD/.ruby-version)" } @test "completes with names of executables" { export RBENV_VERSION="2.0" create_executable "ruby" "#!/bin/sh" create_executable "rake" "#!/bin/sh" rbenv-rehash run rbenv-completions exec assert_success assert_output <" { export RBENV_VERSION="2.0" # emulate `ruby -S' behavior create_executable "ruby" </dev/null; then \$BASH "\$found" else echo "ruby: no Ruby script found in input (LoadError)" >&2 exit 1 fi else echo 'ruby 2.0 (rbenv test)' fi SH create_executable "rake" < "$RBENV_ROOT/version" run rbenv-global assert_success assert_output "1.2.3" } @test "set RBENV_ROOT/version" { mkdir -p "$RBENV_ROOT/versions/1.2.3" run rbenv-global "1.2.3" assert_success run rbenv-global assert_success "1.2.3" } @test "fail setting invalid RBENV_ROOT/version" { mkdir -p "$RBENV_ROOT" run rbenv-global "1.2.3" assert_failure "rbenv: version \`1.2.3' not installed" } rbenv-1.1.1/test/help.bats000066400000000000000000000044711312051774500154230ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper @test "without args shows summary of common commands" { run rbenv-help assert_success assert_line "Usage: rbenv []" assert_line "Some useful rbenv commands are:" } @test "invalid command" { run rbenv-help hello assert_failure "rbenv: no such command \`hello'" } @test "shows help for a specific command" { mkdir -p "${RBENV_TEST_DIR}/bin" cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < # Summary: Says "hello" to you, from rbenv # This command is useful for saying hello. echo hello SH run rbenv-help hello assert_success assert_output < This command is useful for saying hello. SH } @test "replaces missing extended help with summary text" { mkdir -p "${RBENV_TEST_DIR}/bin" cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < # Summary: Says "hello" to you, from rbenv echo hello SH run rbenv-help hello assert_success assert_output < Says "hello" to you, from rbenv SH } @test "extracts only usage" { mkdir -p "${RBENV_TEST_DIR}/bin" cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < # Summary: Says "hello" to you, from rbenv # This extended help won't be shown. echo hello SH run rbenv-help --usage hello assert_success "Usage: rbenv hello " } @test "multiline usage section" { mkdir -p "${RBENV_TEST_DIR}/bin" cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < # rbenv hi [everybody] # rbenv hola --translate # Summary: Says "hello" to you, from rbenv # Help text. echo hello SH run rbenv-help hello assert_success assert_output < rbenv hi [everybody] rbenv hola --translate Help text. SH } @test "multiline extended help section" { mkdir -p "${RBENV_TEST_DIR}/bin" cat > "${RBENV_TEST_DIR}/bin/rbenv-hello" < # Summary: Says "hello" to you, from rbenv # This is extended help text. # It can contain multiple lines. # # And paragraphs. echo hello SH run rbenv-help hello assert_success assert_output < This is extended help text. It can contain multiple lines. And paragraphs. SH } rbenv-1.1.1/test/hooks.bats000066400000000000000000000034631312051774500156160ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper @test "prints usage help given no argument" { run rbenv-hooks assert_failure "Usage: rbenv hooks " } @test "prints list of hooks" { path1="${RBENV_TEST_DIR}/rbenv.d" path2="${RBENV_TEST_DIR}/etc/rbenv_hooks" RBENV_HOOK_PATH="$path1" create_hook exec "hello.bash" create_hook exec "ahoy.bash" create_hook exec "invalid.sh" create_hook which "boom.bash" RBENV_HOOK_PATH="$path2" create_hook exec "bueno.bash" RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec assert_success assert_output </dev/null" } @test "setup shell completions" { root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" run rbenv-init - bash assert_success assert_line "source '${root}/test/../libexec/../completions/rbenv.bash'" } @test "detect parent shell" { SHELL=/bin/false run rbenv-init - assert_success assert_line "export RBENV_SHELL=bash" } @test "detect parent shell from script" { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" cat > myscript.sh </dev/null" } @test "adds shims to PATH" { export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin" run rbenv-init - bash assert_success assert_line 0 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' } @test "adds shims to PATH (fish)" { export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin" run rbenv-init - fish assert_success assert_line 0 "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" } @test "can add shims to PATH more than once" { export PATH="${RBENV_ROOT}/shims:$PATH" run rbenv-init - bash assert_success assert_line 0 'export PATH="'${RBENV_ROOT}'/shims:${PATH}"' } @test "can add shims to PATH more than once (fish)" { export PATH="${RBENV_ROOT}/shims:$PATH" run rbenv-init - fish assert_success assert_line 0 "set -gx PATH '${RBENV_ROOT}/shims' \$PATH" } @test "outputs sh-compatible syntax" { run rbenv-init - bash assert_success assert_line ' case "$command" in' run rbenv-init - zsh assert_success assert_line ' case "$command" in' } @test "outputs fish-specific syntax (fish)" { run rbenv-init - fish assert_success assert_line ' switch "$command"' refute_line ' case "$command" in' } rbenv-1.1.1/test/libexec/000077500000000000000000000000001312051774500152255ustar00rootroot00000000000000rbenv-1.1.1/test/libexec/rbenv-echo000077500000000000000000000002351312051774500172030ustar00rootroot00000000000000#!/usr/bin/env bash # Usage: rbenv echo [-F] VAR if [[ $1 == -F* ]]; then sep="${1:2}" echo "${!2}" | tr "${sep:-:}" $'\n' else echo "${!1}" fi rbenv-1.1.1/test/local.bats000066400000000000000000000023761312051774500155670ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper setup() { mkdir -p "${RBENV_TEST_DIR}/myproject" cd "${RBENV_TEST_DIR}/myproject" } @test "no version" { assert [ ! -e "${PWD}/.ruby-version" ] run rbenv-local assert_failure "rbenv: no local version configured for this directory" } @test "local version" { echo "1.2.3" > .ruby-version run rbenv-local assert_success "1.2.3" } @test "discovers version file in parent directory" { echo "1.2.3" > .ruby-version mkdir -p "subdir" && cd "subdir" run rbenv-local assert_success "1.2.3" } @test "ignores RBENV_DIR" { echo "1.2.3" > .ruby-version mkdir -p "$HOME" echo "2.0-home" > "${HOME}/.ruby-version" RBENV_DIR="$HOME" run rbenv-local assert_success "1.2.3" } @test "sets local version" { mkdir -p "${RBENV_ROOT}/versions/1.2.3" run rbenv-local 1.2.3 assert_success "" assert [ "$(cat .ruby-version)" = "1.2.3" ] } @test "changes local version" { echo "1.0-pre" > .ruby-version mkdir -p "${RBENV_ROOT}/versions/1.2.3" run rbenv-local assert_success "1.0-pre" run rbenv-local 1.2.3 assert_success "" assert [ "$(cat .ruby-version)" = "1.2.3" ] } @test "unsets local version" { touch .ruby-version run rbenv-local --unset assert_success "" assert [ ! -e .ruby-version ] } rbenv-1.1.1/test/prefix.bats000066400000000000000000000021331312051774500157610ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper @test "prefix" { mkdir -p "${RBENV_TEST_DIR}/myproject" cd "${RBENV_TEST_DIR}/myproject" echo "1.2.3" > .ruby-version mkdir -p "${RBENV_ROOT}/versions/1.2.3" run rbenv-prefix assert_success "${RBENV_ROOT}/versions/1.2.3" } @test "prefix for invalid version" { RBENV_VERSION="1.2.3" run rbenv-prefix assert_failure "rbenv: version \`1.2.3' not installed" } @test "prefix for system" { mkdir -p "${RBENV_TEST_DIR}/bin" touch "${RBENV_TEST_DIR}/bin/ruby" chmod +x "${RBENV_TEST_DIR}/bin/ruby" RBENV_VERSION="system" run rbenv-prefix assert_success "$RBENV_TEST_DIR" } @test "prefix for system in /" { mkdir -p "${BATS_TEST_DIRNAME}/libexec" cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" </dev/null || true" assert [ -x "${RBENV_ROOT}/shims/ruby" ] } @test "sh-rehash in fish" { create_executable "2.0" "ruby" RBENV_SHELL=fish run rbenv-sh-rehash assert_success "" assert [ -x "${RBENV_ROOT}/shims/ruby" ] } rbenv-1.1.1/test/run000077500000000000000000000001761312051774500143500ustar00rootroot00000000000000#!/usr/bin/env bash set -e if [ -n "$RBENV_NATIVE_EXT" ]; then src/configure make -C src fi exec bats ${CI:+--tap} test rbenv-1.1.1/test/shell.bats000066400000000000000000000034071312051774500156000ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper @test "no shell version" { mkdir -p "${RBENV_TEST_DIR}/myproject" cd "${RBENV_TEST_DIR}/myproject" echo "1.2.3" > .ruby-version RBENV_VERSION="" run rbenv-sh-shell assert_failure "rbenv: no shell-specific version configured" } @test "shell version" { RBENV_SHELL=bash RBENV_VERSION="1.2.3" run rbenv-sh-shell assert_success 'echo "$RBENV_VERSION"' } @test "shell version (fish)" { RBENV_SHELL=fish RBENV_VERSION="1.2.3" run rbenv-sh-shell assert_success 'echo "$RBENV_VERSION"' } @test "shell revert" { RBENV_SHELL=bash run rbenv-sh-shell - assert_success assert_line 0 'if [ -n "${RBENV_VERSION_OLD+x}" ]; then' } @test "shell revert (fish)" { RBENV_SHELL=fish run rbenv-sh-shell - assert_success assert_line 0 'if set -q RBENV_VERSION_OLD' } @test "shell unset" { RBENV_SHELL=bash run rbenv-sh-shell --unset assert_success assert_output </dev/null || echo "$RBENV_TEST_DIR")" if enable -f "${BATS_TEST_DIRNAME}"/../libexec/rbenv-realpath.dylib realpath 2>/dev/null; then export RBENV_TEST_DIR="$(realpath "$RBENV_TEST_DIR")" else if [ -n "$RBENV_NATIVE_EXT" ]; then echo "rbenv: failed to load \`realpath' builtin" >&2 exit 1 fi fi export RBENV_ROOT="${RBENV_TEST_DIR}/root" export HOME="${RBENV_TEST_DIR}/home" export RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin PATH="${RBENV_TEST_DIR}/bin:$PATH" PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH" PATH="${BATS_TEST_DIRNAME}/libexec:$PATH" PATH="${RBENV_ROOT}/shims:$PATH" export PATH for xdg_var in `env 2>/dev/null | grep ^XDG_ | cut -d= -f1`; do unset "$xdg_var"; done unset xdg_var fi teardown() { rm -rf "$RBENV_TEST_DIR" } flunk() { { if [ "$#" -eq 0 ]; then cat - else echo "$@" fi } | sed "s:${RBENV_TEST_DIR}:TEST_DIR:g" >&2 return 1 } assert_success() { if [ "$status" -ne 0 ]; then flunk "command failed with exit status $status" elif [ "$#" -gt 0 ]; then assert_output "$1" fi } assert_failure() { if [ "$status" -eq 0 ]; then flunk "expected failed exit status" elif [ "$#" -gt 0 ]; then assert_output "$1" fi } assert_equal() { if [ "$1" != "$2" ]; then { echo "expected: $1" echo "actual: $2" } | flunk fi } assert_output() { local expected if [ $# -eq 0 ]; then expected="$(cat -)" else expected="$1" fi assert_equal "$expected" "$output" } assert_line() { if [ "$1" -ge 0 ] 2>/dev/null; then assert_equal "$2" "${lines[$1]}" else local line for line in "${lines[@]}"; do if [ "$line" = "$1" ]; then return 0; fi done flunk "expected line \`$1'" fi } refute_line() { if [ "$1" -ge 0 ] 2>/dev/null; then local num_lines="${#lines[@]}" if [ "$1" -lt "$num_lines" ]; then flunk "output has $num_lines lines" fi else local line for line in "${lines[@]}"; do if [ "$line" = "$1" ]; then flunk "expected to not find line \`$line'" fi done fi } assert() { if ! "$@"; then flunk "failed: $@" fi } # Output a modified PATH that ensures that the given executable is not present, # but in which system utils necessary for rbenv operation are still available. path_without() { local exe="$1" local path=":${PATH}:" local found alt util for found in $(which -a "$exe"); do found="${found%/*}" if [ "$found" != "${RBENV_ROOT}/shims" ]; then alt="${RBENV_TEST_DIR}/$(echo "${found#/}" | tr '/' '-')" mkdir -p "$alt" for util in bash head cut readlink greadlink; do if [ -x "${found}/$util" ]; then ln -s "${found}/$util" "${alt}/$util" fi done path="${path/:${found}:/:${alt}:}" fi done path="${path#:}" echo "${path%:}" } create_hook() { mkdir -p "${RBENV_HOOK_PATH}/$1" touch "${RBENV_HOOK_PATH}/$1/$2" if [ ! -t 0 ]; then cat > "${RBENV_HOOK_PATH}/$1/$2" fi } rbenv-1.1.1/test/version-file-read.bats000066400000000000000000000026661312051774500200120ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper setup() { mkdir -p "${RBENV_TEST_DIR}/myproject" cd "${RBENV_TEST_DIR}/myproject" } @test "fails without arguments" { run rbenv-version-file-read assert_failure "" } @test "fails for invalid file" { run rbenv-version-file-read "non-existent" assert_failure "" } @test "fails for blank file" { echo > my-version run rbenv-version-file-read my-version assert_failure "" } @test "reads simple version file" { cat > my-version <<<"1.9.3" run rbenv-version-file-read my-version assert_success "1.9.3" } @test "ignores leading spaces" { cat > my-version <<<" 1.9.3" run rbenv-version-file-read my-version assert_success "1.9.3" } @test "reads only the first word from file" { cat > my-version <<<"1.9.3-p194@tag 1.8.7 hi" run rbenv-version-file-read my-version assert_success "1.9.3-p194@tag" } @test "loads only the first line in file" { cat > my-version < my-version < my-version run rbenv-version-file-read my-version assert_success "1.8.7" } @test "ignores carriage returns" { cat > my-version <<< $'1.9.3\r' run rbenv-version-file-read my-version assert_success "1.9.3" } rbenv-1.1.1/test/version-file-write.bats000066400000000000000000000014161312051774500202210ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper setup() { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" } @test "invocation without 2 arguments prints usage" { run rbenv-version-file-write assert_failure "Usage: rbenv version-file-write " run rbenv-version-file-write "one" "" assert_failure } @test "setting nonexistent version fails" { assert [ ! -e ".ruby-version" ] run rbenv-version-file-write ".ruby-version" "1.8.7" assert_failure "rbenv: version \`1.8.7' not installed" assert [ ! -e ".ruby-version" ] } @test "writes value to arbitrary file" { mkdir -p "${RBENV_ROOT}/versions/1.8.7" assert [ ! -e "my-version" ] run rbenv-version-file-write "${PWD}/my-version" "1.8.7" assert_success "" assert [ "$(cat my-version)" = "1.8.7" ] } rbenv-1.1.1/test/version-file.bats000066400000000000000000000034721312051774500170750ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper setup() { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" } create_file() { mkdir -p "$(dirname "$1")" touch "$1" } @test "detects global 'version' file" { create_file "${RBENV_ROOT}/version" run rbenv-version-file assert_success "${RBENV_ROOT}/version" } @test "prints global file if no version files exist" { assert [ ! -e "${RBENV_ROOT}/version" ] assert [ ! -e ".ruby-version" ] run rbenv-version-file assert_success "${RBENV_ROOT}/version" } @test "in current directory" { create_file ".ruby-version" run rbenv-version-file assert_success "${RBENV_TEST_DIR}/.ruby-version" } @test "in parent directory" { create_file ".ruby-version" mkdir -p project cd project run rbenv-version-file assert_success "${RBENV_TEST_DIR}/.ruby-version" } @test "topmost file has precedence" { create_file ".ruby-version" create_file "project/.ruby-version" cd project run rbenv-version-file assert_success "${RBENV_TEST_DIR}/project/.ruby-version" } @test "RBENV_DIR has precedence over PWD" { create_file "widget/.ruby-version" create_file "project/.ruby-version" cd project RBENV_DIR="${RBENV_TEST_DIR}/widget" run rbenv-version-file assert_success "${RBENV_TEST_DIR}/widget/.ruby-version" } @test "PWD is searched if RBENV_DIR yields no results" { mkdir -p "widget/blank" create_file "project/.ruby-version" cd project RBENV_DIR="${RBENV_TEST_DIR}/widget/blank" run rbenv-version-file assert_success "${RBENV_TEST_DIR}/project/.ruby-version" } @test "finds version file in target directory" { create_file "project/.ruby-version" run rbenv-version-file "${PWD}/project" assert_success "${RBENV_TEST_DIR}/project/.ruby-version" } @test "fails when no version file in target directory" { run rbenv-version-file "$PWD" assert_failure "" } rbenv-1.1.1/test/version-name.bats000066400000000000000000000035131312051774500170720ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper create_version() { mkdir -p "${RBENV_ROOT}/versions/$1" } setup() { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" } @test "no version selected" { assert [ ! -d "${RBENV_ROOT}/versions" ] run rbenv-version-name assert_success "system" } @test "system version is not checked for existance" { RBENV_VERSION=system run rbenv-version-name assert_success "system" } @test "RBENV_VERSION can be overridden by hook" { create_version "1.8.7" create_version "1.9.3" create_hook version-name test.bash <<<"RBENV_VERSION=1.9.3" RBENV_VERSION=1.8.7 run rbenv-version-name assert_success "1.9.3" } @test "carries original IFS within hooks" { create_hook version-name hello.bash < ".ruby-version" <<<"1.8.7" run rbenv-version-name assert_success "1.8.7" RBENV_VERSION=1.9.3 run rbenv-version-name assert_success "1.9.3" } @test "local file has precedence over global" { create_version "1.8.7" create_version "1.9.3" cat > "${RBENV_ROOT}/version" <<<"1.8.7" run rbenv-version-name assert_success "1.8.7" cat > ".ruby-version" <<<"1.9.3" run rbenv-version-name assert_success "1.9.3" } @test "missing version" { RBENV_VERSION=1.2 run rbenv-version-name assert_failure "rbenv: version \`1.2' is not installed (set by RBENV_VERSION environment variable)" } @test "version with prefix in name" { create_version "1.8.7" cat > ".ruby-version" <<<"ruby-1.8.7" run rbenv-version-name assert_success assert_output "1.8.7" } rbenv-1.1.1/test/version-origin.bats000066400000000000000000000025031312051774500174370ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper setup() { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" } @test "reports global file even if it doesn't exist" { assert [ ! -e "${RBENV_ROOT}/version" ] run rbenv-version-origin assert_success "${RBENV_ROOT}/version" } @test "detects global file" { mkdir -p "$RBENV_ROOT" touch "${RBENV_ROOT}/version" run rbenv-version-origin assert_success "${RBENV_ROOT}/version" } @test "detects RBENV_VERSION" { RBENV_VERSION=1 run rbenv-version-origin assert_success "RBENV_VERSION environment variable" } @test "detects local file" { touch .ruby-version run rbenv-version-origin assert_success "${PWD}/.ruby-version" } @test "reports from hook" { create_hook version-origin test.bash <<<"RBENV_VERSION_ORIGIN=plugin" RBENV_VERSION=1 run rbenv-version-origin assert_success "plugin" } @test "carries original IFS within hooks" { create_hook version-origin hello.bash < ".ruby-version" <<<"1.9.3" run rbenv-version assert_success "1.9.3 (set by ${PWD}/.ruby-version)" } @test "set by global file" { create_version "1.9.3" cat > "${RBENV_ROOT}/version" <<<"1.9.3" run rbenv-version assert_success "1.9.3 (set by ${RBENV_ROOT}/version)" } rbenv-1.1.1/test/versions.bats000066400000000000000000000056531312051774500163460ustar00rootroot00000000000000#!/usr/bin/env bats load test_helper create_version() { mkdir -p "${RBENV_ROOT}/versions/$1" } setup() { mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" } stub_system_ruby() { local stub="${RBENV_TEST_DIR}/bin/ruby" mkdir -p "$(dirname "$stub")" touch "$stub" && chmod +x "$stub" } @test "no versions installed" { stub_system_ruby assert [ ! -d "${RBENV_ROOT}/versions" ] run rbenv-versions assert_success "* system (set by ${RBENV_ROOT}/version)" } @test "not even system ruby available" { PATH="$(path_without ruby)" run rbenv-versions assert_failure assert_output "Warning: no Ruby detected on the system" } @test "bare output no versions installed" { assert [ ! -d "${RBENV_ROOT}/versions" ] run rbenv-versions --bare assert_success "" } @test "single version installed" { stub_system_ruby create_version "1.9" run rbenv-versions assert_success assert_output < "${RBENV_ROOT}/version" <<<"1.9.3" run rbenv-versions assert_success assert_output < ".ruby-version" <<<"1.9.3" run rbenv-versions assert_success assert_output < "${RBENV_ROOT}/version" <<<"1.8" create_executable "1.8" "ruby" mkdir -p "$RBENV_TEST_DIR" cd "$RBENV_TEST_DIR" RBENV_VERSION= run rbenv-which ruby assert_success "${RBENV_ROOT}/versions/1.8/bin/ruby" }