mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-08 11:33:49 -05:00
Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9375e99f92 | ||
|
|
b66eeaf2f7 | ||
|
|
c6855e01a9 | ||
|
|
7f975a37f9 | ||
|
|
41cfa5f3d0 | ||
|
|
9c45206c28 | ||
|
|
308aa42b67 | ||
|
|
5174d14d5c | ||
|
|
6fe338e563 | ||
|
|
266d896871 | ||
|
|
7e85ae7bd2 | ||
|
|
9a284a3da4 | ||
|
|
871f0e26df | ||
|
|
e56885f4c9 | ||
|
|
149f4b4607 | ||
|
|
80750f730f | ||
|
|
253f6ee1d9 | ||
|
|
bac149e824 | ||
|
|
3ec34448fa | ||
|
|
919c4240fc | ||
|
|
44c2378f2a | ||
|
|
377b176260 | ||
|
|
d2a8ca7d89 | ||
|
|
d4faae187a | ||
|
|
5e52fae7c1 | ||
|
|
b974bf54dc | ||
|
|
4b6c91e827 | ||
|
|
51467dc4a3 | ||
|
|
eb79a3edaa | ||
|
|
37eca782cc | ||
|
|
19666f2598 | ||
|
|
3436bddaea | ||
|
|
5cc6b0e3d3 | ||
|
|
2b21e22e97 | ||
|
|
57df945738 | ||
|
|
e2e474c59d | ||
|
|
4c19dc22d7 | ||
|
|
ef44b4ccac | ||
|
|
8ee2f2657a | ||
|
|
f635c8715c | ||
|
|
3ceeb72ac6 | ||
|
|
e0b8938fef | ||
|
|
811ca05916 | ||
|
|
df9bbd7ab3 | ||
|
|
339e331f1d | ||
|
|
283e67b57e | ||
|
|
6c1fb9ffd0 | ||
|
|
c3fe192243 | ||
|
|
1ebcbd92e2 | ||
|
|
3060578e3b | ||
|
|
b8715bfee6 | ||
|
|
7fe9231e64 | ||
|
|
9289af0132 | ||
|
|
1f7722088d | ||
|
|
e548877ead | ||
|
|
21391c8d2f | ||
|
|
99551dd1ec | ||
|
|
b5a26936e8 | ||
|
|
cf28136003 | ||
|
|
349236c932 | ||
|
|
0ce6fad14e | ||
|
|
0a9e2baef1 | ||
|
|
da562ad74c | ||
|
|
d45dc17f25 | ||
|
|
7f1aefa09b | ||
|
|
2162054659 | ||
|
|
0ff3ca8a12 | ||
|
|
47c8a0e0b8 | ||
|
|
2a347226df | ||
|
|
962452d6d1 | ||
|
|
2df165c49e | ||
|
|
fc3a634e22 | ||
|
|
01a9141780 | ||
|
|
f783b9ec0d | ||
|
|
b745a51f30 | ||
|
|
02332d78f3 | ||
|
|
183c780698 | ||
|
|
406c8e0303 | ||
|
|
6778c8e905 | ||
|
|
3a94daeaf8 | ||
|
|
e5c64db280 | ||
|
|
d3700dfd70 | ||
|
|
975b45dbfe | ||
|
|
a49b07975c | ||
|
|
5e57ab95ce | ||
|
|
9c43fa9161 | ||
|
|
9b286ecbfd | ||
|
|
b7e9569ccb | ||
|
|
e922131422 | ||
|
|
34813ef32c | ||
|
|
e899f1d31c | ||
|
|
d1bfeee334 | ||
|
|
9ea1f7d53e | ||
|
|
f40bc773d2 | ||
|
|
5d0a6630b9 | ||
|
|
114b81c9a4 |
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2011 Sam Stephenson
|
||||
Copyright (c) 2013 Sam Stephenson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
463
README.md
463
README.md
@@ -1,176 +1,246 @@
|
||||
# Simple Ruby Version Management: rbenv
|
||||
# Groom your app’s Ruby environment with rbenv.
|
||||
|
||||
rbenv lets you easily switch between multiple versions of Ruby. It's
|
||||
simple, unobtrusive, and follows the UNIX tradition of single-purpose
|
||||
tools that do one thing well.
|
||||
Use rbenv to pick a Ruby version for your application and guarantee
|
||||
that your development environment matches production. Put rbenv to work
|
||||
with [Bundler](http://gembundler.com/) for painless Ruby upgrades and
|
||||
bulletproof deployments.
|
||||
|
||||
<img src="http://i.sstephenson.us/rbenv2.png" width="894" height="464">
|
||||
**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.
|
||||
|
||||
### rbenv _does…_
|
||||
**Rock-solid in production.** Your application's executables are its
|
||||
interface with ops. With rbenv and [Bundler
|
||||
binstubs](https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs)
|
||||
you'll never again need to `cd` in a cron job or Chef recipe to
|
||||
ensure you've selected the right runtime. The Ruby version
|
||||
dependency lives in one place—your app—so upgrades and rollbacks are
|
||||
atomic, even when you switch versions.
|
||||
|
||||
* Let you **change the global Ruby version** on a per-user basis.
|
||||
* Provide support for **per-project Ruby versions**.
|
||||
* Allow you to **override the Ruby version** with an environment
|
||||
variable.
|
||||
**One thing well.** rbenv is concerned solely with switching Ruby
|
||||
versions. It's simple and predictable. A rich plugin ecosystem lets
|
||||
you tailor it to suit your needs. Compile your own Ruby versions, or
|
||||
use the [ruby-build](https://github.com/sstephenson/ruby-build)
|
||||
plugin to automate the process. Specify per-application environment
|
||||
variables with [rbenv-vars](https://github.com/sstephenson/rbenv-vars).
|
||||
See more [plugins on the
|
||||
wiki](https://github.com/sstephenson/rbenv/wiki/Plugins).
|
||||
|
||||
### In contrast with rvm, rbenv _does not…_
|
||||
|
||||
* **Need to be loaded into your shell.** Instead, rbenv's shim
|
||||
approach works by adding a directory to your `$PATH`.
|
||||
* **Override shell commands like `cd`.** That's dangerous and
|
||||
error-prone.
|
||||
* **Have a configuration file.** There's nothing to configure except
|
||||
which version of Ruby you want to use.
|
||||
* **Install Ruby.** You can build and install Ruby yourself, or use
|
||||
[ruby-build](https://github.com/sstephenson/ruby-build) to
|
||||
automate the process.
|
||||
* **Manage gemsets.** [Bundler](http://gembundler.com/) is a better
|
||||
way to manage application dependencies. If you have projects that
|
||||
are not yet using Bundler you can install the
|
||||
[rbenv-gemset](https://github.com/jamis/rbenv-gemset) plugin.
|
||||
* **Require changes to Ruby libraries for compatibility.** The
|
||||
simplicity of rbenv means as long as it's in your `$PATH`,
|
||||
[nothing](https://rvm.beginrescueend.com/integration/bundler/)
|
||||
[else](https://rvm.beginrescueend.com/integration/capistrano/)
|
||||
needs to know about it.
|
||||
* **Prompt you with warnings when you switch to a project.** Instead
|
||||
of executing arbitrary code, rbenv reads just the version name
|
||||
from each project. There's nothing to "trust."
|
||||
[**Why choose rbenv over
|
||||
RVM?**](https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [1 How It Works](#section_1)
|
||||
* [2 Installation](#section_2)
|
||||
* [2.1 Basic GitHub Checkout](#section_2.1)
|
||||
* [2.1.1 Upgrading](#section_2.1.1)
|
||||
* [2.2 Homebrew on Mac OS X](#section_2.2)
|
||||
* [2.3 Neckbeard Configuration](#section_2.3)
|
||||
* [3 Usage](#section_3)
|
||||
* [3.1 rbenv global](#section_3.1)
|
||||
* [3.2 rbenv local](#section_3.2)
|
||||
* [3.3 rbenv shell](#section_3.3)
|
||||
* [3.4 rbenv versions](#section_3.4)
|
||||
* [3.5 rbenv version](#section_3.5)
|
||||
* [3.6 rbenv rehash](#section_3.6)
|
||||
* [3.7 rbenv which](#section_3.7)
|
||||
* [3.8 rbenv whence](#section_3.8)
|
||||
* [4 Development](#section_4)
|
||||
* [4.1 Version History](#section_4.1)
|
||||
* [4.2 License](#section_4.2)
|
||||
* [How It Works](#how-it-works)
|
||||
* [Understanding PATH](#understanding-path)
|
||||
* [Understanding Shims](#understanding-shims)
|
||||
* [Choosing the Ruby Version](#choosing-the-ruby-version)
|
||||
* [Locating the Ruby Installation](#locating-the-ruby-installation)
|
||||
* [Installation](#installation)
|
||||
* [Basic GitHub Checkout](#basic-github-checkout)
|
||||
* [Upgrading](#upgrading)
|
||||
* [Homebrew on Mac OS X](#homebrew-on-mac-os-x)
|
||||
* [Neckbeard Configuration](#neckbeard-configuration)
|
||||
* [Uninstalling Ruby Versions](#uninstalling-ruby-versions)
|
||||
* [Command Reference](#command-reference)
|
||||
* [rbenv local](#rbenv-local)
|
||||
* [rbenv global](#rbenv-global)
|
||||
* [rbenv shell](#rbenv-shell)
|
||||
* [rbenv versions](#rbenv-versions)
|
||||
* [rbenv version](#rbenv-version)
|
||||
* [rbenv rehash](#rbenv-rehash)
|
||||
* [rbenv which](#rbenv-which)
|
||||
* [rbenv whence](#rbenv-whence)
|
||||
* [Development](#development)
|
||||
* [Version History](#version-history)
|
||||
* [License](#license)
|
||||
|
||||
## <a name="section_1"></a> 1 How It Works
|
||||
## How It Works
|
||||
|
||||
rbenv operates on the per-user directory `~/.rbenv`. Version names in
|
||||
rbenv correspond to subdirectories of `~/.rbenv/versions`. For
|
||||
example, you might have `~/.rbenv/versions/1.8.7-p354` and
|
||||
`~/.rbenv/versions/1.9.3-rc1`.
|
||||
At at high level, rbenv intercepts Ruby commands using shim
|
||||
executables injected into your `PATH`, determines which Ruby version
|
||||
has been specified by your application, and passes your commands along
|
||||
to the correct Ruby installation.
|
||||
|
||||
Each version is a working tree with its own binaries, like
|
||||
`~/.rbenv/versions/1.8.7-p354/bin/ruby` and
|
||||
`~/.rbenv/versions/1.9.3-rc1/bin/irb`. rbenv makes _shim binaries_
|
||||
for every such binary across all installed versions of Ruby.
|
||||
### Understanding PATH
|
||||
|
||||
These shims are simple wrapper scripts that live in `~/.rbenv/shims`
|
||||
and detect which Ruby version you want to use. They insert the
|
||||
directory for the selected version at the beginning of your `$PATH`
|
||||
and then execute the corresponding binary.
|
||||
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:
|
||||
|
||||
Because of the simplicity of the shim approach, all you need to use
|
||||
rbenv is `~/.rbenv/shims` in your `$PATH`.
|
||||
/usr/local/bin:/usr/bin:/bin
|
||||
|
||||
## <a name="section_2"></a> 2 Installation
|
||||
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`.
|
||||
|
||||
**Compatibility note**: rbenv is _incompatible_ with rvm. Things will
|
||||
appear to work until you try to install a gem. The problem is that
|
||||
rvm actually overrides the `gem` command with a shell function!
|
||||
Please remove any references to rvm before using rbenv.
|
||||
### Understanding Shims
|
||||
|
||||
### <a name="section_2.1"></a> 2.1 Basic GitHub Checkout
|
||||
rbenv works by inserting a directory of _shims_ at the front of your
|
||||
`PATH`:
|
||||
|
||||
~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin
|
||||
|
||||
Through a process called _rehashing_, rbenv maintains shims in that
|
||||
directory to match every Ruby command across every installed version
|
||||
of Ruby—`irb`, `gem`, `rake`, `rails`, `ruby`, and so on.
|
||||
|
||||
Shims are lightweight executables that simply pass your command along
|
||||
to rbenv. So with rbenv installed, when you run, say, `rake`, your
|
||||
operating system will do the following:
|
||||
|
||||
* Search your `PATH` for an executable file named `rake`
|
||||
* Find the rbenv shim named `rake` at the beginning of your `PATH`
|
||||
* Run the shim named `rake`, which in turn passes the command along to
|
||||
rbenv
|
||||
|
||||
### Choosing the Ruby Version
|
||||
|
||||
When you execute a shim, rbenv determines which Ruby version to use by
|
||||
reading it from the following sources, in this order:
|
||||
|
||||
1. The `RBENV_VERSION` environment variable, if specified. You can use
|
||||
the [`rbenv shell`](#rbenv-shell) command to set this environment
|
||||
variable in your current shell session.
|
||||
|
||||
2. The application-specific `.ruby-version` file in the current
|
||||
directory, if present. You can modify the current directory's
|
||||
`.ruby-version` file with the [`rbenv local`](#rbenv-local)
|
||||
command.
|
||||
|
||||
3. The first `.ruby-version` file found by searching each parent
|
||||
directory until reaching the root of your filesystem, if any.
|
||||
|
||||
4. The global `~/.rbenv/version` file. You can modify this file using
|
||||
the [`rbenv global`](#rbenv-global) command. If the global version
|
||||
file is not present, rbenv assumes you want to use the "system"
|
||||
Ruby—i.e. whatever version would be run if rbenv weren't in your
|
||||
path.
|
||||
|
||||
### Locating the Ruby Installation
|
||||
|
||||
Once rbenv has determined which version of Ruby your application has
|
||||
specified, it passes the command along to the corresponding Ruby
|
||||
installation.
|
||||
|
||||
Each Ruby version is installed into its own directory under
|
||||
`~/.rbenv/versions`. For example, you might have these versions
|
||||
installed:
|
||||
|
||||
* `~/.rbenv/versions/1.8.7-p371/`
|
||||
* `~/.rbenv/versions/1.9.3-p327/`
|
||||
* `~/.rbenv/versions/jruby-1.7.1/`
|
||||
|
||||
Version names to rbenv are simply the names of the directories in
|
||||
`~/.rbenv/versions`.
|
||||
|
||||
## Installation
|
||||
|
||||
**Compatibility note**: rbenv is _incompatible_ with RVM. Please make
|
||||
sure to fully uninstall RVM and remove any references to it from
|
||||
your shell initialization files before installing rbenv.
|
||||
|
||||
If you're on Mac OS X, consider
|
||||
[installing with Homebrew](#homebrew-on-mac-os-x).
|
||||
|
||||
### Basic GitHub Checkout
|
||||
|
||||
This will get you going with the latest version of rbenv and make it
|
||||
easy to fork and contribute any changes back upstream.
|
||||
|
||||
1. Check out rbenv into `~/.rbenv`.
|
||||
|
||||
$ cd
|
||||
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
|
||||
~~~ sh
|
||||
$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
|
||||
~~~
|
||||
|
||||
2. Add `~/.rbenv/bin` to your `$PATH` for access to the `rbenv`
|
||||
command-line utility.
|
||||
|
||||
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
||||
~~~ sh
|
||||
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
||||
~~~
|
||||
|
||||
**Zsh note**: Modifiy your `~/.zshenv` file instead of `~/.bash_profile`.
|
||||
**Ubuntu note**: Modify your `~/.profile` instead of `~/.bash_profile`.
|
||||
|
||||
3. Add rbenv init to your shell to enable shims and autocompletion.
|
||||
**Zsh note**: Modify your `~/.zshrc` file instead of `~/.bash_profile`.
|
||||
|
||||
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
|
||||
3. Add `rbenv init` to your shell to enable shims and autocompletion.
|
||||
|
||||
**Zsh note**: Modifiy your `~/.zshenv` file instead of `~/.bash_profile`.
|
||||
~~~ sh
|
||||
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
|
||||
~~~
|
||||
|
||||
4. Restart your shell so the path changes take effect. You can now
|
||||
begin using rbenv.
|
||||
_Same as in previous step, use `~/.profile` on Ubuntu, `~/.zshrc` for zsh._
|
||||
|
||||
$ exec $SHELL
|
||||
4. Restart your shell as a login shell so the path changes take effect.
|
||||
You can now begin using rbenv.
|
||||
|
||||
5. Install Ruby versions into `~/.rbenv/versions`. For example, to
|
||||
install Ruby 1.9.2-p290, download and unpack the source, then run:
|
||||
~~~ sh
|
||||
$ exec $SHELL -l
|
||||
~~~
|
||||
|
||||
$ ./configure --prefix=$HOME/.rbenv/versions/1.9.2-p290
|
||||
$ make
|
||||
$ make install
|
||||
5. Install [ruby-build](https://github.com/sstephenson/ruby-build),
|
||||
which provides an `rbenv install` command that simplifies the
|
||||
process of installing new Ruby versions.
|
||||
|
||||
The [ruby-build](https://github.com/sstephenson/ruby-build) project
|
||||
provides an `rbenv install` command that simplifies the process of
|
||||
installing new Ruby versions to:
|
||||
~~~
|
||||
$ rbenv install 1.9.3-p327
|
||||
~~~
|
||||
|
||||
$ rbenv install 1.9.2-p290
|
||||
As an alternative, you can download and compile Ruby yourself into
|
||||
`~/.rbenv/versions/`.
|
||||
|
||||
6. Rebuild the shim binaries. You should do this any time you install
|
||||
a new Ruby binary (for example, when installing a new Ruby version,
|
||||
or when installing a gem that provides a binary).
|
||||
6. Rebuild the shim executables. You should do this any time you
|
||||
install a new Ruby executable (for example, when installing a new
|
||||
Ruby version, or when installing a gem that provides a command).
|
||||
|
||||
$ rbenv rehash
|
||||
~~~
|
||||
$ rbenv rehash
|
||||
~~~
|
||||
|
||||
#### <a name="section_2.1.1"></a> 2.1.1 Upgrading
|
||||
#### Upgrading
|
||||
|
||||
If you've installed rbenv using the instructions above, you can
|
||||
upgrade your installation at any time using git.
|
||||
If you've installed rbenv manually using git, you can upgrade your
|
||||
installation to the cutting-edge version at any time.
|
||||
|
||||
To upgrade to the latest development version of rbenv, use `git pull`:
|
||||
~~~ sh
|
||||
$ cd ~/.rbenv
|
||||
$ git pull
|
||||
~~~
|
||||
|
||||
$ cd ~/.rbenv
|
||||
$ git pull
|
||||
To use a specific release of rbenv, check out the corresponding tag:
|
||||
|
||||
To upgrade to a specific release of rbenv, check out the corresponding
|
||||
tag:
|
||||
~~~ sh
|
||||
$ cd ~/.rbenv
|
||||
$ git fetch
|
||||
$ git checkout v0.3.0
|
||||
~~~
|
||||
|
||||
$ cd ~/.rbenv
|
||||
$ git fetch
|
||||
$ git tag
|
||||
v0.1.0
|
||||
v0.1.1
|
||||
v0.1.2
|
||||
v0.2.0
|
||||
$ git checkout v0.2.0
|
||||
|
||||
### <a name="section_2.2"></a> 2.2 Homebrew on Mac OS X
|
||||
### Homebrew on Mac OS X
|
||||
|
||||
You can also install rbenv using the
|
||||
[Homebrew](http://mxcl.github.com/homebrew/) package manager on Mac OS
|
||||
X.
|
||||
|
||||
$ brew update
|
||||
$ brew install rbenv
|
||||
$ brew install ruby-build
|
||||
~~~
|
||||
$ brew update
|
||||
$ brew install rbenv
|
||||
$ brew install ruby-build
|
||||
~~~
|
||||
|
||||
The same commands can be used for upgrading.
|
||||
To later update these installs, use `upgrade` instead of `install`.
|
||||
|
||||
Afterwards you'll still need to add `eval "$(rbenv init -)"` to your
|
||||
profile as stated in the caveats. You'll only ever have to do this
|
||||
once.
|
||||
|
||||
### <a name="section_2.3"></a> 2.3 Neckbeard Configuration
|
||||
### Neckbeard Configuration
|
||||
|
||||
Skip this section unless you must know what every line in your shell
|
||||
profile is doing.
|
||||
@@ -202,19 +272,53 @@ opposed to this idea. Here's what `rbenv init` actually does:
|
||||
Run `rbenv init -` for yourself to see exactly what happens under the
|
||||
hood.
|
||||
|
||||
## <a name="section_3"></a> 3 Usage
|
||||
### Uninstalling Ruby Versions
|
||||
|
||||
As time goes on, Ruby versions you install will accumulate in your
|
||||
`~/.rbenv/versions` directory.
|
||||
|
||||
To remove old Ruby versions, simply `rm -rf` the directory of the
|
||||
version you want to remove. You can find the directory of a particular
|
||||
Ruby verison with the `rbenv prefix` command, e.g. `rbenv prefix
|
||||
1.8.7-p357`.
|
||||
|
||||
The [ruby-build](https://github.com/sstephenson/ruby-build) plugin
|
||||
provides an `rbenv uninstall` command to automate the removal
|
||||
process.
|
||||
|
||||
## Command Reference
|
||||
|
||||
Like `git`, the `rbenv` command delegates to subcommands based on its
|
||||
first argument. The most common subcommands are:
|
||||
|
||||
### <a name="section_3.1"></a> 3.1 rbenv global
|
||||
### rbenv local
|
||||
|
||||
Sets a local application-specific Ruby version by writing the version
|
||||
name to a `.ruby-version` file in the current directory. This version
|
||||
overrides the global version, and can be overridden itself by setting
|
||||
the `RBENV_VERSION` environment variable or with the `rbenv shell`
|
||||
command.
|
||||
|
||||
$ rbenv local 1.9.3-p327
|
||||
|
||||
When run without a version number, `rbenv local` reports the currently
|
||||
configured local version. You can also unset the local version:
|
||||
|
||||
$ rbenv local --unset
|
||||
|
||||
Previous versions of rbenv stored local version specifications in a
|
||||
file named `.rbenv-version`. For backwards compatibility, rbenv will
|
||||
read a local version specified in an `.rbenv-version` file, but a
|
||||
`.ruby-version` file in the same directory will take precedence.
|
||||
|
||||
### rbenv global
|
||||
|
||||
Sets the global version of Ruby to be used in all shells by writing
|
||||
the version name to the `~/.rbenv/version` file. This version can be
|
||||
overridden by a per-project `.rbenv-version` file, or by setting the
|
||||
`RBENV_VERSION` environment variable.
|
||||
overridden by an application-specific `.ruby-version` file, or by
|
||||
setting the `RBENV_VERSION` environment variable.
|
||||
|
||||
$ rbenv global 1.9.2-p290
|
||||
$ rbenv global 1.8.7-p352
|
||||
|
||||
The special version name `system` tells rbenv to use the system Ruby
|
||||
(detected by searching your `$PATH`).
|
||||
@@ -222,28 +326,13 @@ The special version name `system` tells rbenv to use the system Ruby
|
||||
When run without a version number, `rbenv global` reports the
|
||||
currently configured global version.
|
||||
|
||||
### <a name="section_3.2"></a> 3.2 rbenv local
|
||||
|
||||
Sets a local per-project Ruby version by writing the version name to
|
||||
an `.rbenv-version` file in the current directory. This version
|
||||
overrides the global, and can be overridden itself by setting the
|
||||
`RBENV_VERSION` environment variable or with the `rbenv shell`
|
||||
command.
|
||||
|
||||
$ rbenv local rbx-1.2.4
|
||||
|
||||
When run without a version number, `rbenv local` reports the currently
|
||||
configured local version. You can also unset the local version:
|
||||
|
||||
$ rbenv local --unset
|
||||
|
||||
### <a name="section_3.3"></a> 3.3 rbenv shell
|
||||
### rbenv shell
|
||||
|
||||
Sets a shell-specific Ruby version by setting the `RBENV_VERSION`
|
||||
environment variable in your shell. This version overrides both
|
||||
project-specific versions and the global version.
|
||||
environment variable in your shell. This version overrides
|
||||
application-specific versions and the global version.
|
||||
|
||||
$ rbenv shell jruby-1.6.4
|
||||
$ 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:
|
||||
@@ -255,9 +344,9 @@ 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.6.4
|
||||
$ export RBENV_VERSION=jruby-1.7.1
|
||||
|
||||
### <a name="section_3.4"></a> 3.4 rbenv versions
|
||||
### rbenv versions
|
||||
|
||||
Lists all Ruby versions known to rbenv, and shows an asterisk next to
|
||||
the currently active version.
|
||||
@@ -265,45 +354,45 @@ the currently active version.
|
||||
$ rbenv versions
|
||||
1.8.7-p352
|
||||
1.9.2-p290
|
||||
* 1.9.3-rc1 (set by /Users/sam/.rbenv/global)
|
||||
jruby-1.6.4
|
||||
* 1.9.3-p327 (set by /Users/sam/.rbenv/version)
|
||||
jruby-1.7.1
|
||||
rbx-1.2.4
|
||||
ree-1.8.7-2011.03
|
||||
|
||||
### <a name="section_3.5"></a> 3.5 rbenv version
|
||||
### rbenv version
|
||||
|
||||
Displays the currently active Ruby version, along with information on
|
||||
how it was set.
|
||||
|
||||
$ rbenv version
|
||||
1.8.7-p352 (set by /Volumes/37signals/basecamp/.rbenv-version)
|
||||
1.8.7-p352 (set by /Volumes/37signals/basecamp/.ruby-version)
|
||||
|
||||
### <a name="section_3.6"></a> 3.6 rbenv rehash
|
||||
### rbenv rehash
|
||||
|
||||
Installs shims for all Ruby binaries known to rbenv (i.e.,
|
||||
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 binaries.
|
||||
version of Ruby, or install a gem that provides commands.
|
||||
|
||||
$ rbenv rehash
|
||||
|
||||
### <a name="section_3.7"></a> 3.7 rbenv which
|
||||
### rbenv which
|
||||
|
||||
Displays the full path to the binary that rbenv will execute when you
|
||||
run the given command.
|
||||
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.2-p290/bin/irb
|
||||
/Users/sam/.rbenv/versions/1.9.3-p327/bin/irb
|
||||
|
||||
### <a name="section_3.8"></a> 3.8 rbenv whence
|
||||
### rbenv whence
|
||||
|
||||
Lists all Ruby versions with the given command installed.
|
||||
|
||||
$ rbenv whence rackup
|
||||
1.9.3-rc1
|
||||
jruby-1.6.4
|
||||
1.9.3-p327
|
||||
jruby-1.7.1
|
||||
ree-1.8.7-2011.03
|
||||
|
||||
## <a name="section_4"></a> 4 Development
|
||||
## Development
|
||||
|
||||
The rbenv source code is [hosted on
|
||||
GitHub](https://github.com/sstephenson/rbenv). It's clean, modular,
|
||||
@@ -312,7 +401,57 @@ and easy to understand, even if you're not a shell hacker.
|
||||
Please feel free to submit pull requests and file bugs on the [issue
|
||||
tracker](https://github.com/sstephenson/rbenv/issues).
|
||||
|
||||
### <a name="section_4.1"></a> 4.1 Version History
|
||||
### Version History
|
||||
|
||||
**0.4.0** (January 4, 2013)
|
||||
|
||||
* rbenv now prefers `.ruby-version` files to `.rbenv-version` files
|
||||
for specifying local application-specific versions. The
|
||||
`.ruby-version` file has the same format as `.rbenv-version` but is
|
||||
[compatible with other Ruby version
|
||||
managers](https://gist.github.com/1912050).
|
||||
* Deprecated `ruby-local-exec` and moved its functionality into the
|
||||
standard `ruby` shim. See the [ruby-local-exec wiki
|
||||
page](https://github.com/sstephenson/wiki/ruby-local-exec) for
|
||||
upgrade instructions.
|
||||
* Modified shims to include the full path to rbenv so that they can be
|
||||
invoked without having rbenv's bin directory in the `$PATH`.
|
||||
* Sped up `rbenv init` by avoiding rbenv reinintialization and by
|
||||
using a simpler indexing approach. (Users of
|
||||
[chef-rbenv](https://github.com/fnichol/chef-rbenv) should upgrade
|
||||
to the latest version to fix a [compatibility
|
||||
issue](https://github.com/fnichol/chef-rbenv/pull/26).)
|
||||
* Reworked `rbenv help` so that usage and documentation is stored as a
|
||||
comment in each subcommand, enabling plugin commands to hook into
|
||||
the help system.
|
||||
* Added support for full completion of the command line, not just the
|
||||
first argument.
|
||||
* Updated installation instructions for Zsh and Ubuntu users.
|
||||
* Fixed `rbenv which` and `rbenv prefix` with system Ruby versions.
|
||||
* Changed `rbenv exec` to avoid prepending the system Ruby location to
|
||||
`$PATH` to fix issues running system Ruby commands that invoke other
|
||||
commands.
|
||||
* Changed `rbenv rehash` to ensure it exits with a 0 status code under
|
||||
normal operation, and to ensure outdated shims are removed first
|
||||
when rehashing.
|
||||
* Modified `rbenv rehash` to run `hash -r` afterwards, when shell
|
||||
integration is enabled, to ensure the shell's command cache is
|
||||
cleared.
|
||||
* Removed use of the `+=` operator to support older versions of Bash.
|
||||
* Adjusted non-bare `rbenv versions` output to include `system`, if
|
||||
present.
|
||||
* Improved documentation for installing and uninstalling Ruby
|
||||
versions.
|
||||
* Fixed `rbenv versions` not to display a warning if the currently
|
||||
specified version doesn't exist.
|
||||
* Fixed an instance of local variable leakage in the `rbenv` shell
|
||||
function wrapper.
|
||||
* Changed `rbenv shell` to ensure it exits with a non-zero status on
|
||||
failure.
|
||||
* Added `rbenv --version` for printing the current version of rbenv.
|
||||
* Added `/usr/lib/rbenv/hooks` to the plugin hook search path.
|
||||
* Fixed `rbenv which` to account for path entries with spaces.
|
||||
* Changed `rbenv init` to accept option arguments in any order.
|
||||
|
||||
**0.3.0** (December 25, 2011)
|
||||
|
||||
@@ -388,11 +527,11 @@ tracker](https://github.com/sstephenson/rbenv/issues).
|
||||
|
||||
* Initial public release.
|
||||
|
||||
### <a name="section_4.2"></a> 4.2 License
|
||||
### License
|
||||
|
||||
(The MIT license)
|
||||
|
||||
Copyright (c) 2011 Sam Stephenson
|
||||
Copyright (c) 2013 Sam Stephenson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -13,4 +13,11 @@
|
||||
|
||||
set -e
|
||||
export RBENV_DIR="${1%/*}"
|
||||
|
||||
[ -n "$RBENV_SILENCE_WARNINGS" ] || {
|
||||
echo "rbenv: \`ruby-local-exec' is deprecated and will be removed in the next release."
|
||||
echo " To upgrade: https://github.com/sstephenson/rbenv/wiki/ruby-local-exec"
|
||||
echo
|
||||
} >&2
|
||||
|
||||
exec ruby "$@"
|
||||
|
||||
@@ -5,8 +5,10 @@ _rbenv() {
|
||||
if [ "$COMP_CWORD" -eq 1 ]; then
|
||||
COMPREPLY=( $(compgen -W "$(rbenv commands)" -- "$word") )
|
||||
else
|
||||
local command="${COMP_WORDS[1]}"
|
||||
local completions="$(rbenv completions "$command")"
|
||||
local words=("${COMP_WORDS[@]}")
|
||||
unset words[0]
|
||||
unset words[$COMP_CWORD]
|
||||
local completions=$(rbenv completions "${words[@]}")
|
||||
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -5,14 +5,13 @@ fi
|
||||
compctl -K _rbenv rbenv
|
||||
|
||||
_rbenv() {
|
||||
local word words completions
|
||||
local words completions
|
||||
read -cA words
|
||||
word="${words[2]}"
|
||||
|
||||
if [ "${#words}" -eq 2 ]; then
|
||||
completions="$(rbenv commands)"
|
||||
else
|
||||
completions="$(rbenv completions "${word}")"
|
||||
completions="$(rbenv completions ${words[2,-1]})"
|
||||
fi
|
||||
|
||||
reply=("${(ps:\n:)completions}")
|
||||
|
||||
395
doc/README.mdtoc
395
doc/README.mdtoc
@@ -1,395 +0,0 @@
|
||||
# Simple Ruby Version Management: rbenv
|
||||
|
||||
rbenv lets you easily switch between multiple versions of Ruby. It's
|
||||
simple, unobtrusive, and follows the UNIX tradition of single-purpose
|
||||
tools that do one thing well.
|
||||
|
||||
<img src="http://i.sstephenson.us/rbenv2.png" width="894" height="464">
|
||||
|
||||
### rbenv _does…_
|
||||
|
||||
* Let you **change the global Ruby version** on a per-user basis.
|
||||
* Provide support for **per-project Ruby versions**.
|
||||
* Allow you to **override the Ruby version** with an environment
|
||||
variable.
|
||||
|
||||
### In contrast with rvm, rbenv _does not…_
|
||||
|
||||
* **Need to be loaded into your shell.** Instead, rbenv's shim
|
||||
approach works by adding a directory to your `$PATH`.
|
||||
* **Override shell commands like `cd`.** That's dangerous and
|
||||
error-prone.
|
||||
* **Have a configuration file.** There's nothing to configure except
|
||||
which version of Ruby you want to use.
|
||||
* **Install Ruby.** You can build and install Ruby yourself, or use
|
||||
[ruby-build](https://github.com/sstephenson/ruby-build) to
|
||||
automate the process.
|
||||
* **Manage gemsets.** [Bundler](http://gembundler.com/) is a better
|
||||
way to manage application dependencies. If you have projects that
|
||||
are not yet using Bundler you can install the
|
||||
[rbenv-gemset](https://github.com/jamis/rbenv-gemset) plugin.
|
||||
* **Require changes to Ruby libraries for compatibility.** The
|
||||
simplicity of rbenv means as long as it's in your `$PATH`,
|
||||
[nothing](https://rvm.beginrescueend.com/integration/bundler/)
|
||||
[else](https://rvm.beginrescueend.com/integration/capistrano/)
|
||||
needs to know about it.
|
||||
* **Prompt you with warnings when you switch to a project.** Instead
|
||||
of executing arbitrary code, rbenv reads just the version name
|
||||
from each project. There's nothing to "trust."
|
||||
|
||||
## Table of Contents
|
||||
|
||||
## How It Works ##
|
||||
|
||||
rbenv operates on the per-user directory `~/.rbenv`. Version names in
|
||||
rbenv correspond to subdirectories of `~/.rbenv/versions`. For
|
||||
example, you might have `~/.rbenv/versions/1.8.7-p354` and
|
||||
`~/.rbenv/versions/1.9.3-rc1`.
|
||||
|
||||
Each version is a working tree with its own binaries, like
|
||||
`~/.rbenv/versions/1.8.7-p354/bin/ruby` and
|
||||
`~/.rbenv/versions/1.9.3-rc1/bin/irb`. rbenv makes _shim binaries_
|
||||
for every such binary across all installed versions of Ruby.
|
||||
|
||||
These shims are simple wrapper scripts that live in `~/.rbenv/shims`
|
||||
and detect which Ruby version you want to use. They insert the
|
||||
directory for the selected version at the beginning of your `$PATH`
|
||||
and then execute the corresponding binary.
|
||||
|
||||
Because of the simplicity of the shim approach, all you need to use
|
||||
rbenv is `~/.rbenv/shims` in your `$PATH`.
|
||||
|
||||
## Installation ##
|
||||
|
||||
**Compatibility note**: rbenv is _incompatible_ with rvm. Things will
|
||||
appear to work until you try to install a gem. The problem is that
|
||||
rvm actually overrides the `gem` command with a shell function!
|
||||
Please remove any references to rvm before using rbenv.
|
||||
|
||||
### 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`.
|
||||
|
||||
$ cd
|
||||
$ git clone git://github.com/sstephenson/rbenv.git .rbenv
|
||||
|
||||
2. Add `~/.rbenv/bin` to your `$PATH` for access to the `rbenv`
|
||||
command-line utility.
|
||||
|
||||
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
|
||||
|
||||
**Zsh note**: Modifiy your `~/.zshenv` file instead of `~/.bash_profile`.
|
||||
|
||||
3. Add rbenv init to your shell to enable shims and autocompletion.
|
||||
|
||||
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
|
||||
|
||||
**Zsh note**: Modifiy your `~/.zshenv` file instead of `~/.bash_profile`.
|
||||
|
||||
4. Restart your shell so the path changes take effect. You can now
|
||||
begin using rbenv.
|
||||
|
||||
$ exec $SHELL
|
||||
|
||||
5. Install Ruby versions into `~/.rbenv/versions`. For example, to
|
||||
install Ruby 1.9.2-p290, download and unpack the source, then run:
|
||||
|
||||
$ ./configure --prefix=$HOME/.rbenv/versions/1.9.2-p290
|
||||
$ make
|
||||
$ make install
|
||||
|
||||
The [ruby-build](https://github.com/sstephenson/ruby-build) project
|
||||
provides an `rbenv install` command that simplifies the process of
|
||||
installing new Ruby versions to:
|
||||
|
||||
$ rbenv install 1.9.2-p290
|
||||
|
||||
6. Rebuild the shim binaries. You should do this any time you install
|
||||
a new Ruby binary (for example, when installing a new Ruby version,
|
||||
or when installing a gem that provides a binary).
|
||||
|
||||
$ rbenv rehash
|
||||
|
||||
#### Upgrading ####
|
||||
|
||||
If you've installed rbenv using the instructions above, you can
|
||||
upgrade your installation at any time using git.
|
||||
|
||||
To upgrade to the latest development version of rbenv, use `git pull`:
|
||||
|
||||
$ cd ~/.rbenv
|
||||
$ git pull
|
||||
|
||||
To upgrade to a specific release of rbenv, check out the corresponding
|
||||
tag:
|
||||
|
||||
$ cd ~/.rbenv
|
||||
$ git fetch
|
||||
$ git tag
|
||||
v0.1.0
|
||||
v0.1.1
|
||||
v0.1.2
|
||||
v0.2.0
|
||||
$ git checkout v0.2.0
|
||||
|
||||
### Homebrew on Mac OS X ###
|
||||
|
||||
You can also install rbenv using the
|
||||
[Homebrew](http://mxcl.github.com/homebrew/) package manager on Mac OS
|
||||
X.
|
||||
|
||||
$ brew update
|
||||
$ brew install rbenv
|
||||
$ brew install ruby-build
|
||||
|
||||
The same commands can be used for upgrading.
|
||||
|
||||
Afterwards you'll still need to add `eval "$(rbenv init -)"` to your
|
||||
profile as stated in the caveats. You'll only ever have to do this
|
||||
once.
|
||||
|
||||
### Neckbeard Configuration ###
|
||||
|
||||
Skip this section unless you must know what every line in your shell
|
||||
profile is doing.
|
||||
|
||||
`rbenv init` is the only command that crosses the line of loading
|
||||
extra commands into your shell. Coming from rvm, some of you might be
|
||||
opposed to this idea. Here's what `rbenv init` actually does:
|
||||
|
||||
1. Sets up your shims path. This is the only requirement for rbenv to
|
||||
function properly. You can do this by hand by prepending
|
||||
`~/.rbenv/shims` to your `$PATH`.
|
||||
|
||||
2. Installs autocompletion. This is entirely optional but pretty
|
||||
useful. Sourcing `~/.rbenv/completions/rbenv.bash` will set that
|
||||
up. There is also a `~/.rbenv/completions/rbenv.zsh` for Zsh
|
||||
users.
|
||||
|
||||
3. Rehashes shims. From time to time you'll need to rebuild your
|
||||
shim files. Doing this on init makes sure everything is up to
|
||||
date. You can always run `rbenv rehash` manually.
|
||||
|
||||
4. Installs the sh dispatcher. This bit is also optional, but allows
|
||||
rbenv and plugins to change variables in your current shell, making
|
||||
commands like `rbenv shell` possible. The sh dispatcher doesn't do
|
||||
anything crazy like override `cd` or hack your shell prompt, but if
|
||||
for some reason you need `rbenv` to be a real script rather than a
|
||||
shell function, you can safely skip it.
|
||||
|
||||
Run `rbenv init -` for yourself to see exactly what happens under the
|
||||
hood.
|
||||
|
||||
## Usage ##
|
||||
|
||||
Like `git`, the `rbenv` command delegates to subcommands based on its
|
||||
first argument. The most common subcommands are:
|
||||
|
||||
### 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 a per-project `.rbenv-version` file, or by setting the
|
||||
`RBENV_VERSION` environment variable.
|
||||
|
||||
$ rbenv global 1.9.2-p290
|
||||
|
||||
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 local ###
|
||||
|
||||
Sets a local per-project Ruby version by writing the version name to
|
||||
an `.rbenv-version` file in the current directory. This version
|
||||
overrides the global, and can be overridden itself by setting the
|
||||
`RBENV_VERSION` environment variable or with the `rbenv shell`
|
||||
command.
|
||||
|
||||
$ rbenv local rbx-1.2.4
|
||||
|
||||
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 shell ###
|
||||
|
||||
Sets a shell-specific Ruby version by setting the `RBENV_VERSION`
|
||||
environment variable in your shell. This version overrides both
|
||||
project-specific versions and the global version.
|
||||
|
||||
$ rbenv shell jruby-1.6.4
|
||||
|
||||
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.6.4
|
||||
|
||||
### 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-rc1 (set by /Users/sam/.rbenv/global)
|
||||
jruby-1.6.4
|
||||
rbx-1.2.4
|
||||
ree-1.8.7-2011.03
|
||||
|
||||
### rbenv version ###
|
||||
|
||||
Displays the currently active Ruby version, along with information on
|
||||
how it was set.
|
||||
|
||||
$ rbenv version
|
||||
1.8.7-p352 (set by /Volumes/37signals/basecamp/.rbenv-version)
|
||||
|
||||
### rbenv rehash ###
|
||||
|
||||
Installs shims for all Ruby binaries 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 binaries.
|
||||
|
||||
$ rbenv rehash
|
||||
|
||||
### rbenv which ###
|
||||
|
||||
Displays the full path to the binary that rbenv will execute when you
|
||||
run the given command.
|
||||
|
||||
$ rbenv which irb
|
||||
/Users/sam/.rbenv/versions/1.9.2-p290/bin/irb
|
||||
|
||||
### rbenv whence ###
|
||||
|
||||
Lists all Ruby versions with the given command installed.
|
||||
|
||||
$ rbenv whence rackup
|
||||
1.9.3-rc1
|
||||
jruby-1.6.4
|
||||
ree-1.8.7-2011.03
|
||||
|
||||
## Development ##
|
||||
|
||||
The rbenv source code is [hosted on
|
||||
GitHub](https://github.com/sstephenson/rbenv). It's clean, modular,
|
||||
and easy to understand, even if you're not a shell hacker.
|
||||
|
||||
Please feel free to submit pull requests and file bugs on the [issue
|
||||
tracker](https://github.com/sstephenson/rbenv/issues).
|
||||
|
||||
### Version History ###
|
||||
|
||||
**0.3.0** (December 25, 2011)
|
||||
|
||||
* Added an `rbenv root` command which prints the value of
|
||||
`$RBENV_ROOT`, or the default root directory if it's unset.
|
||||
* Clarified Zsh installation instructions in the readme.
|
||||
* Removed some redundant code in `rbenv rehash`.
|
||||
* Fixed an issue with calling `readlink` for paths with spaces.
|
||||
* Changed Zsh initialization code to install completion hooks only for
|
||||
interactive shells.
|
||||
* Added preliminary support for ksh.
|
||||
* `rbenv rehash` creates or removes shims only when necessary instead
|
||||
of removing and re-creating all shims on each invocation.
|
||||
* Fixed that `RBENV_DIR`, when specified, would be incorrectly
|
||||
expanded to its parent directory.
|
||||
* Removed the deprecated `set-default` and `set-local` commands.
|
||||
* Added a `--no-rehash` option to `rbenv init` for skipping the
|
||||
automatic rehash when opening a new shell.
|
||||
|
||||
**0.2.1** (October 1, 2011)
|
||||
|
||||
* Changed the `rbenv` command to ensure that `RBENV_DIR` is always an
|
||||
absolute path. This fixes an issue where Ruby scripts using the
|
||||
`ruby-local-exec` wrapper would go into an infinite loop when
|
||||
invoked with a relative path from the command line.
|
||||
|
||||
**0.2.0** (September 28, 2011)
|
||||
|
||||
* Renamed `rbenv set-default` to `rbenv global` and `rbenv set-local`
|
||||
to `rbenv local`. The `set-` commands are deprecated and will be
|
||||
removed in the next major release.
|
||||
* rbenv now uses `greadlink` on Solaris.
|
||||
* Added a `ruby-local-exec` command which can be used in shebangs in
|
||||
place of `#!/usr/bin/env ruby` to properly set the project-specific
|
||||
Ruby version regardless of current working directory.
|
||||
* Fixed an issue with `rbenv rehash` when no binaries are present.
|
||||
* Added support for `rbenv-sh-*` commands, which run inside the
|
||||
current shell instead of in a child process.
|
||||
* Added an `rbenv shell` command for conveniently setting the
|
||||
`$RBENV_VERSION` environment variable.
|
||||
* Added support for storing rbenv versions and shims in directories
|
||||
other than `~/.rbenv` with the `$RBENV_ROOT` environment variable.
|
||||
* Added support for debugging rbenv via `set -x` when the
|
||||
`$RBENV_DEBUG` environment variable is set.
|
||||
* Refactored the autocompletion system so that completions are now
|
||||
built-in to each command and shared between bash and Zsh.
|
||||
* Added support for plugin bundles in `~/.rbenv/plugins` as documented
|
||||
in [issue #102](https://github.com/sstephenson/rbenv/pull/102).
|
||||
* Added `/usr/local/etc/rbenv.d` to the list of directories searched
|
||||
for rbenv hooks.
|
||||
* Added support for an `$RBENV_DIR` environment variable which
|
||||
defaults to the current working directory for specifying where rbenv
|
||||
searches for local version files.
|
||||
|
||||
**0.1.2** (August 16, 2011)
|
||||
|
||||
* Fixed rbenv to be more resilient against nonexistent entries in
|
||||
`$PATH`.
|
||||
* Made the `rbenv rehash` command operate atomically.
|
||||
* Modified the `rbenv init` script to automatically run `rbenv
|
||||
rehash` so that shims are recreated whenever a new shell is opened.
|
||||
* Added initial support for Zsh autocompletion.
|
||||
* Removed the dependency on egrep for reading version files.
|
||||
|
||||
**0.1.1** (August 14, 2011)
|
||||
|
||||
* Fixed a syntax error in the `rbenv help` command.
|
||||
* Removed `-e` from the shebang in favor of `set -e` at the top of
|
||||
each file for compatibility with operating systems that do not
|
||||
support more than one argument in the shebang.
|
||||
|
||||
**0.1.0** (August 11, 2011)
|
||||
|
||||
* Initial public release.
|
||||
|
||||
### License ###
|
||||
|
||||
(The MIT license)
|
||||
|
||||
Copyright (c) 2011 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.
|
||||
82
doc/mdtoc.rb
82
doc/mdtoc.rb
@@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# A little Markdown filter that scans your document for headings,
|
||||
# numbers them, adds anchors, and inserts a table of contents.
|
||||
#
|
||||
# To use it, make sure the headings you want numbered and linked are
|
||||
# in this format:
|
||||
#
|
||||
# ### Title ###
|
||||
#
|
||||
# I.e. they must have an equal number of octothorpes around the title
|
||||
# text. (In Markdown, `#` means `h1`, `##` means `h2`, and so on.)
|
||||
# The table of contents will be inserted before the first such
|
||||
# heading.
|
||||
#
|
||||
# Released into the public domain.
|
||||
# Sam Stephenson <sstephenson@gmail.com>
|
||||
# 2011-04-30
|
||||
|
||||
def mdtoc(markdown)
|
||||
titles = []
|
||||
lines = markdown.split($/)
|
||||
start = nil
|
||||
|
||||
# First pass: Scan the Markdown source looking for titles of the
|
||||
# format: `### Title ###`. Record the line number, header level
|
||||
# (number of octothorpes), and text of each matching title.
|
||||
lines.each_with_index do |line, line_no|
|
||||
if line.match(/^(\#{1,6})\s+(.+?)\s+\1$/)
|
||||
titles << [line_no, $1.length, $2]
|
||||
start ||= line_no
|
||||
end
|
||||
end
|
||||
|
||||
last_section = nil
|
||||
last_level = nil
|
||||
|
||||
# Second pass: Iterate over all matched titles and compute their
|
||||
# corresponding section numbers. Then replace the titles with
|
||||
# annotated anchors.
|
||||
titles.each do |title_info|
|
||||
line_no, level, text = title_info
|
||||
|
||||
if last_section
|
||||
section = last_section.dup
|
||||
|
||||
if last_level < level
|
||||
section << 1
|
||||
else
|
||||
(last_level - level).times { section.pop }
|
||||
section[-1] += 1
|
||||
end
|
||||
else
|
||||
section = [1]
|
||||
end
|
||||
|
||||
name = section.join(".")
|
||||
lines[line_no] = %(#{"#" * level} <a name="section_#{name}"></a> #{name} #{text})
|
||||
|
||||
title_info << section
|
||||
last_section = section
|
||||
last_level = level
|
||||
end
|
||||
|
||||
# Third pass: Iterate over matched titles once more to produce the
|
||||
# table of contents. Then insert it immediately above the first
|
||||
# matched title.
|
||||
if start
|
||||
toc = titles.map do |(line_no, level, text, section)|
|
||||
name = section.join(".")
|
||||
%(#{" " * (section.length * 3)}* [#{name} #{text}](#section_#{name}))
|
||||
end + [""]
|
||||
|
||||
lines.insert(start, *toc)
|
||||
end
|
||||
|
||||
lines.join("\n")
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
puts mdtoc($<.read)
|
||||
end
|
||||
@@ -48,7 +48,7 @@ for plugin_bin in "${RBENV_ROOT}/plugins/"*/bin; do
|
||||
done
|
||||
export PATH="${bin_path}:${PATH}"
|
||||
|
||||
hook_path="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d"
|
||||
hook_path="${RBENV_HOOK_PATH}:${RBENV_ROOT}/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks"
|
||||
for plugin_hook in "${RBENV_ROOT}/plugins/"*/etc/rbenv.d; do
|
||||
hook_path="${hook_path}:${plugin_hook}"
|
||||
done
|
||||
@@ -60,7 +60,10 @@ shopt -u nullglob
|
||||
command="$1"
|
||||
case "$command" in
|
||||
"" | "-h" | "--help" )
|
||||
echo -e "rbenv 0.3.0\n$(rbenv-help)" >&2
|
||||
echo -e "$(rbenv---version)\n$(rbenv-help)" >&2
|
||||
;;
|
||||
"-v" )
|
||||
exec rbenv---version
|
||||
;;
|
||||
* )
|
||||
command_path="$(command -v "rbenv-$command" || true)"
|
||||
|
||||
21
libexec/rbenv---version
Executable file
21
libexec/rbenv---version
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/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:
|
||||
# <version>-<num_commits>-<git_sha>
|
||||
# where `num_commits` is the number of commits since `version` was
|
||||
# tagged.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
version="0.4.0"
|
||||
|
||||
cd "$RBENV_ROOT"
|
||||
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
|
||||
git_revision="${git_revision#v}"
|
||||
|
||||
echo "rbenv ${git_revision:-$version}"
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: List all available rbenv commands
|
||||
# Usage: rbenv commands [--sh|--no-sh]
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Usage: rbenv completions <command> [arg1 arg2...]
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
COMMAND="$1"
|
||||
if [ -z "$COMMAND" ]; then
|
||||
echo "usage: rbenv completions COMMAND [arg1 arg2...]" >&2
|
||||
rbenv-help --usage completions >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Summary: Run an executable with the selected Ruby version
|
||||
#
|
||||
# Usage: rbenv exec <command> [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
|
||||
|
||||
@@ -7,9 +21,11 @@ if [ "$1" = "--complete" ]; then
|
||||
exec rbenv shims --short
|
||||
fi
|
||||
|
||||
export RBENV_VERSION="$(rbenv-version-name)"
|
||||
RBENV_COMMAND="$1"
|
||||
|
||||
if [ -z "$RBENV_COMMAND" ]; then
|
||||
echo "usage: rbenv exec COMMAND [arg1 arg2...]" >&2
|
||||
rbenv-help --usage exec >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -21,5 +37,7 @@ for script in $(rbenv-hooks exec); do
|
||||
done
|
||||
|
||||
shift 1
|
||||
export PATH="${RBENV_BIN_PATH}:${PATH}"
|
||||
if [ "$RBENV_VERSION" != "system" ]; then
|
||||
export PATH="${RBENV_BIN_PATH}:${PATH}"
|
||||
fi
|
||||
exec -a "$RBENV_COMMAND" "$RBENV_COMMAND_PATH" "$@"
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Summary: Set or show the global Ruby version
|
||||
#
|
||||
# Usage: rbenv global <version>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# <version> should be a string matching a Ruby version known to rbenv.
|
||||
# The special version string `system' will use your default system Ruby.
|
||||
# Run `rbenv versions' for a list of available Ruby versions.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
|
||||
@@ -1,88 +1,162 @@
|
||||
#!/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
|
||||
|
||||
print_set_version() {
|
||||
echo "<version> should be a string matching a Ruby version known by rbenv."
|
||||
|
||||
local versions="$(rbenv-versions --bare)"
|
||||
if [ -z "$versions" ]; then
|
||||
echo "There are currently no Ruby versions installed for rbenv."
|
||||
else
|
||||
echo "The currently installed Ruby versions are:"
|
||||
echo "$versions" | sed 's/^/ /'
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "The special version string 'system' will use your default system Ruby."
|
||||
command_path() {
|
||||
local command="$1"
|
||||
command -v rbenv-"$command" || command -v rbenv-sh-"$command" || true
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"") echo "usage: rbenv <command> [<args>]
|
||||
extract_initial_comment_block() {
|
||||
sed -ne "
|
||||
/^#/ !{
|
||||
q
|
||||
}
|
||||
|
||||
Some useful rbenv commands are:
|
||||
commands List all rbenv commands
|
||||
rehash Rehash rbenv shims (run this after installing binaries)
|
||||
global Set or show the global Ruby version
|
||||
local Set or show the local directory-specific Ruby version
|
||||
shell Set or show the shell-specific Ruby version
|
||||
version Show the current Ruby version
|
||||
versions List all Ruby versions known by rbenv
|
||||
which Show the full path for the given Ruby command
|
||||
whence List all Ruby versions with the given command
|
||||
s/^#$/# /
|
||||
|
||||
See 'rbenv help <command>' for information on a specific command.
|
||||
For full documentation, see: https://github.com/sstephenson/rbenv#readme"
|
||||
;;
|
||||
global) echo "usage: rbenv global <version>
|
||||
/^# / {
|
||||
s/^# //
|
||||
p
|
||||
}
|
||||
"
|
||||
}
|
||||
|
||||
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.
|
||||
collect_documentation() {
|
||||
awk '
|
||||
/^Summary:/ {
|
||||
summary = substr($0, 10)
|
||||
next
|
||||
}
|
||||
|
||||
$(print_set_version)"
|
||||
;;
|
||||
local) echo "usage: rbenv local <version>
|
||||
rbenv local --unset
|
||||
/^Usage:/ {
|
||||
reading_usage = 1
|
||||
usage = usage "\n" $0
|
||||
next
|
||||
}
|
||||
|
||||
Sets the local directory-specific Ruby version by writing the version
|
||||
name to a file named '.rbenv-version'.
|
||||
/^( *$| )/ && reading_usage {
|
||||
usage = usage "\n" $0
|
||||
next
|
||||
}
|
||||
|
||||
When you run a Ruby command, rbenv will look for an '.rbenv-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', or the version specified in the
|
||||
RBENV_VERSION environment variable.
|
||||
{
|
||||
reading_usage = 0
|
||||
help = help "\n" $0
|
||||
}
|
||||
|
||||
$(print_set_version)"
|
||||
;;
|
||||
shell) echo "usage: rbenv shell <version>
|
||||
rbenv shell --unset
|
||||
function escape(str) {
|
||||
gsub(/[`\\$"]/, "\\\\&", str)
|
||||
return str
|
||||
}
|
||||
|
||||
Sets a shell-specific Ruby version by setting the 'RBENV_VERSION'
|
||||
environment variable in your shell. This version overrides both
|
||||
project-specific versions and the global version.
|
||||
function trim(str) {
|
||||
gsub(/^\n*/, "", str)
|
||||
gsub(/\n*$/, "", str)
|
||||
return str
|
||||
}
|
||||
|
||||
$(print_set_version)"
|
||||
;;
|
||||
which) echo "usage: rbenv which <command>
|
||||
END {
|
||||
if (usage || summary) {
|
||||
print "summary=\"" escape(summary) "\""
|
||||
print "usage=\"" escape(trim(usage)) "\""
|
||||
print "help=\"" escape(trim(help)) "\""
|
||||
}
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
Displays the full path to the binary that rbenv will execute when you
|
||||
run the given command."
|
||||
;;
|
||||
whence) echo "usage: rbenv whence <command>
|
||||
|
||||
Lists all Ruby versions with the given command installed."
|
||||
;;
|
||||
*)
|
||||
command_path="$(command -v "rbenv-$1" || true)"
|
||||
if [ -n "$command_path" ]; then
|
||||
echo "Sorry, the \`$1' command isn't documented yet."
|
||||
echo
|
||||
echo "You can view the command's source here:"
|
||||
echo "$command_path"
|
||||
echo
|
||||
else
|
||||
echo "rbenv: no such command \`$1'"
|
||||
documentation_for() {
|
||||
local filename="$(command_path "$1")"
|
||||
if [ -n "$filename" ]; then
|
||||
extract_initial_comment_block < "$filename" | collect_documentation
|
||||
fi
|
||||
esac
|
||||
}
|
||||
|
||||
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 <command> [<args>]"
|
||||
[ -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 <command>' for information on a specific command."
|
||||
echo "For full documentation, see: https://github.com/sstephenson/rbenv#readme"
|
||||
else
|
||||
command="$1"
|
||||
if [ -n "$(command_path "$command")" ]; then
|
||||
if [ -n "$usage" ]; then
|
||||
print_usage "$command"
|
||||
else
|
||||
print_help "$command"
|
||||
fi
|
||||
else
|
||||
echo "rbenv: no such command \`$command'" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: List hook scripts for a given rbenv command
|
||||
# Usage: rbenv hooks <command>
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -12,7 +15,7 @@ fi
|
||||
|
||||
RBENV_COMMAND="$1"
|
||||
if [ -z "$RBENV_COMMAND" ]; then
|
||||
echo "usage: rbenv hooks COMMAND" >&2
|
||||
rbenv-help --usage hooks >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Configure the shell environment for rbenv
|
||||
# Usage: eval "$(rbenv init - [--no-rehash] [<shell>])"
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
print=""
|
||||
if [ "$1" = "-" ]; then
|
||||
print=1
|
||||
shift
|
||||
fi
|
||||
|
||||
no_rehash=""
|
||||
if [ "$1" = "--no-rehash" ]; then
|
||||
no_rehash=1
|
||||
shift
|
||||
fi
|
||||
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
|
||||
@@ -79,10 +85,11 @@ if [ -z "$no_rehash" ]; then
|
||||
echo 'rbenv rehash 2>/dev/null'
|
||||
fi
|
||||
|
||||
commands=(`rbenv commands --sh`)
|
||||
commands=(`rbenv-commands --sh`)
|
||||
IFS="|"
|
||||
cat <<EOS
|
||||
rbenv() {
|
||||
typeset command
|
||||
command="\$1"
|
||||
if [ "\$#" -gt 0 ]; then
|
||||
shift
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Summary: Set or show the local application-specific Ruby version
|
||||
#
|
||||
# Usage: rbenv local <version>
|
||||
# rbenv local --unset
|
||||
#
|
||||
# Sets the local application-specific Ruby version by writing the
|
||||
# version name to a file named `.ruby-version'.
|
||||
#
|
||||
# When you run a Ruby command, rbenv will look for a `.ruby-version'
|
||||
# file in the current directory and each parent directory. If no such
|
||||
# file is found in the tree, rbenv will use the global Ruby version
|
||||
# specified with `rbenv global'. A version specified with the
|
||||
# `RBENV_VERSION' environment variable takes precedence over local
|
||||
# and global versions.
|
||||
#
|
||||
# For backwards compatibility, rbenv will also read version
|
||||
# specifications from `.rbenv-version' files, but a `.ruby-version'
|
||||
# file in the same directory takes precedence.
|
||||
#
|
||||
# <version> should be a string matching a Ruby version known to rbenv.
|
||||
# The special version string `system' will use your default system Ruby.
|
||||
# Run `rbenv versions' for a list of available Ruby versions.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -10,14 +34,20 @@ if [ "$1" = "--complete" ]; then
|
||||
fi
|
||||
|
||||
RBENV_VERSION="$1"
|
||||
RBENV_VERSION_FILE=".rbenv-version"
|
||||
|
||||
if [ "$RBENV_VERSION" = "--unset" ]; then
|
||||
rm -f "$RBENV_VERSION_FILE"
|
||||
rm -f .ruby-version .rbenv-version
|
||||
elif [ -n "$RBENV_VERSION" ]; then
|
||||
rbenv-version-file-write "$RBENV_VERSION_FILE" "$RBENV_VERSION"
|
||||
if [ "$(RBENV_VERSION= rbenv-version-origin)" -ef .rbenv-version ]; then
|
||||
rm -f .rbenv-version
|
||||
{ echo "rbenv: removed existing \`.rbenv-version' file and migrated"
|
||||
echo " local version specification to \`.ruby-version' file"
|
||||
} >&2
|
||||
fi
|
||||
rbenv-version-file-write .ruby-version "$RBENV_VERSION"
|
||||
else
|
||||
rbenv-version-file-read "$RBENV_VERSION_FILE" ||
|
||||
rbenv-version-file-read .ruby-version ||
|
||||
rbenv-version-file-read .rbenv-version ||
|
||||
{ echo "rbenv: no local version configured for this directory"
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Display prefix for a Ruby version
|
||||
# Usage: rbenv prefix [<version>]
|
||||
#
|
||||
# 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
|
||||
|
||||
@@ -16,7 +23,8 @@ fi
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
RUBY_PATH="$(rbenv-which ruby)"
|
||||
echo "${RUBY_PATH%/*}"
|
||||
RUBY_PATH="${RUBY_PATH%/*}"
|
||||
echo "${RUBY_PATH%/bin}"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Rehash rbenv shims (run this after installing executables)
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -30,19 +32,48 @@ remove_prototype_shim() {
|
||||
|
||||
# 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 binary and then removed. The linking technique
|
||||
# is fast, uses less disk space than unique files, and also serves as
|
||||
# a locking mechanism.
|
||||
# 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" <<SH
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
[ -n "\$RBENV_DEBUG" ] && set -x
|
||||
|
||||
program="\${0##*/}"
|
||||
if [ "\$program" = "ruby" ]; then
|
||||
for arg; do
|
||||
case "\$arg" in
|
||||
-e* | -- ) break ;;
|
||||
*/* )
|
||||
if [ -f "\$arg" ]; then
|
||||
export RBENV_DIR="\${arg%/*}"
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
export RBENV_ROOT="$RBENV_ROOT"
|
||||
exec rbenv exec "\${0##*/}" "\$@"
|
||||
exec "$(command -v rbenv)" exec "\$program" "\$@"
|
||||
SH
|
||||
chmod +x "$PROTOTYPE_SHIM_PATH"
|
||||
}
|
||||
|
||||
# If the contents of the prototype shim file differ from the contents
|
||||
# of the first shim in the shims directory, assume rbenv has been
|
||||
# upgraded and the existing shims need to be removed.
|
||||
remove_outdated_shims() {
|
||||
for shim in *; do
|
||||
if ! diff "$PROTOTYPE_SHIM_PATH" "$shim" >/dev/null 2>&1; then
|
||||
for shim in *; do rm -f "$shim"; done
|
||||
fi
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
# The basename of each argument passed to `make_shims` will be
|
||||
# registered for installation as a shim. In this way, plugins may call
|
||||
# `make_shims` with a glob to register many shims at once.
|
||||
@@ -55,58 +86,27 @@ make_shims() {
|
||||
done
|
||||
}
|
||||
|
||||
# Create an empty array for the list of registered shims.
|
||||
# Create an empty array for the list of registered shims and an empty
|
||||
# string to use as a search index.
|
||||
registered_shims=()
|
||||
registered_shims_index=""
|
||||
|
||||
# We will keep track of shims registered for installation with the
|
||||
# global `reigstered_shims` array and with a global variable for each
|
||||
# shim. The array will let us iterate over all registered shims. The
|
||||
# global variables will let us quickly check whether a shim with the
|
||||
# given name has been registered or not.
|
||||
# global `reigstered_shims` array and with a global search index
|
||||
# string. The array will let us iterate over all registered shims. The
|
||||
# index string will let us quickly check whether a shim with the given
|
||||
# name has been registered or not.
|
||||
register_shim() {
|
||||
local shim="$@"
|
||||
local var="$(shim_variable_name "$shim")"
|
||||
|
||||
if [ -z "${!var}" ]; then
|
||||
registered_shims[${#registered_shims[*]}]="$shim"
|
||||
eval "${var}=1"
|
||||
fi
|
||||
}
|
||||
|
||||
# To compute the global variable name for a given shim we must first
|
||||
# escape any non-alphanumeric characters. If the shim name is
|
||||
# alphanumeric (including a hyphen or underscore) we can take a
|
||||
# shorter path. Otherwise, we must iterate over each character and
|
||||
# escape the non-alphanumeric ones using `printf`.
|
||||
shim_variable_name() {
|
||||
local shim="$1"
|
||||
local result="_shim_"
|
||||
|
||||
if [[ ! "$shim" =~ [^[:alnum:]_-] ]]; then
|
||||
shim="${shim//_/_5f}"
|
||||
shim="${shim//-/_2d}"
|
||||
result+="$shim"
|
||||
else
|
||||
local length="${#shim}"
|
||||
local char i
|
||||
|
||||
for ((i=0; i<length; i++)); do
|
||||
char="${shim:$i:1}"
|
||||
if [[ "$char" =~ [[:alnum:]] ]]; then
|
||||
result+="$char"
|
||||
else
|
||||
result+="$(printf "_%02x" \'"$char")"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
registered_shims["${#registered_shims[@]}"]="$shim"
|
||||
registered_shims_index="$registered_shims_index/$shim/"
|
||||
}
|
||||
|
||||
# To install all the registered shims, we iterate over the
|
||||
# `registered_shims` array and create a link if one does not already
|
||||
# exist.
|
||||
install_registered_shims() {
|
||||
local shim
|
||||
for shim in "${registered_shims[@]}"; do
|
||||
[ -e "$shim" ] || ln -f "$PROTOTYPE_SHIM_PATH" "$shim"
|
||||
done
|
||||
@@ -117,20 +117,23 @@ install_registered_shims() {
|
||||
# in the directory but has not been registered as a shim should be
|
||||
# removed.
|
||||
remove_stale_shims() {
|
||||
local var
|
||||
local shim
|
||||
for shim in *; do
|
||||
var="$(shim_variable_name "$shim")"
|
||||
[ -z "${!var}" ] && rm -f "$shim"
|
||||
if [[ "$registered_shims_index" != *"/$shim/"* ]]; then
|
||||
rm -f "$shim"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Change to the shims directory.
|
||||
cd "$SHIM_PATH"
|
||||
|
||||
# Create the prototype shim, then register shims for all known binaries.
|
||||
create_prototype_shim
|
||||
shopt -s nullglob
|
||||
|
||||
# Create the prototype shim, then register shims for all known
|
||||
# executables.
|
||||
create_prototype_shim
|
||||
remove_outdated_shims
|
||||
make_shims ../versions/*/bin/*
|
||||
|
||||
# Restore the previous working directory.
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Display the root directory where versions and shims are kept
|
||||
echo $RBENV_ROOT
|
||||
|
||||
13
libexec/rbenv-sh-rehash
Executable file
13
libexec/rbenv-sh-rehash
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
# Provide rbenv completions
|
||||
if [ "$1" = "--complete" ]; then
|
||||
exec rbenv-rehash --complete
|
||||
fi
|
||||
|
||||
# When rbenv shell integration is enabled, delegate to rbenv-rehash,
|
||||
# then tell the shell to empty its command lookup cache.
|
||||
rbenv-rehash
|
||||
echo "hash -r"
|
||||
@@ -1,4 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Summary: Set or show the shell-specific Ruby version
|
||||
#
|
||||
# Usage: rbenv shell <version>
|
||||
# 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.
|
||||
#
|
||||
# <version> should be a string matching a Ruby version known to rbenv.
|
||||
# The special version string `system' will use your default system Ruby.
|
||||
# Run `rbenv versions' for a list of available Ruby versions.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -23,10 +37,13 @@ fi
|
||||
|
||||
if [ "$version" = "--unset" ]; then
|
||||
echo "unset RBENV_VERSION"
|
||||
exit 1
|
||||
exit
|
||||
fi
|
||||
|
||||
# Make sure the specified version is installed.
|
||||
rbenv-prefix "$version" >/dev/null
|
||||
|
||||
echo "export RBENV_VERSION=\"${version}\""
|
||||
if rbenv-prefix "$version" >/dev/null; then
|
||||
echo "export RBENV_VERSION=\"${version}\""
|
||||
else
|
||||
echo "return 1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: List existing rbenv shims
|
||||
# Usage: rbenv shims [--short]
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#!/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
|
||||
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Detect the file that sets the current rbenv version
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
root="$RBENV_DIR"
|
||||
while [ -n "$root" ]; do
|
||||
if [ -e "${root}/.rbenv-version" ]; then
|
||||
echo "${root}/.rbenv-version"
|
||||
exit
|
||||
fi
|
||||
root="${root%/*}"
|
||||
done
|
||||
find_local_version_file() {
|
||||
local root="$1"
|
||||
while [ -n "$root" ]; do
|
||||
if [ -e "${root}/.ruby-version" ]; then
|
||||
echo "${root}/.ruby-version"
|
||||
exit
|
||||
elif [ -e "${root}/.rbenv-version" ]; then
|
||||
echo "${root}/.rbenv-version"
|
||||
exit
|
||||
fi
|
||||
root="${root%/*}"
|
||||
done
|
||||
}
|
||||
|
||||
find_local_version_file "$RBENV_DIR"
|
||||
[ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
|
||||
|
||||
global_version_file="${RBENV_ROOT}/version"
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Usage: rbenv version-file-read <file>
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
VERSION_FILE="$1"
|
||||
|
||||
if [ -e "$VERSION_FILE" ]; then
|
||||
# Read and print the first non-whitespace word from the specified
|
||||
# version file.
|
||||
# Read the first non-whitespace word from the specified version file.
|
||||
# Be careful not to load it whole in case there's something crazy in it.
|
||||
version=""
|
||||
while read -a words; do
|
||||
word="${words[0]}"
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Usage: rbenv version-file-write <file> <version>
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -6,7 +8,7 @@ RBENV_VERSION_FILE="$1"
|
||||
RBENV_VERSION="$2"
|
||||
|
||||
if [ -z "$RBENV_VERSION" ] || [ -z "$RBENV_VERSION_FILE" ]; then
|
||||
echo "usage: rbenv write-version-file FILENAME VERSION" >&2
|
||||
rbenv-help --usage version-file-write >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Show the current Ruby version
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -12,10 +13,18 @@ if [ -z "$RBENV_VERSION" ] || [ "$RBENV_VERSION" = "system" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
RBENV_VERSION_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}"
|
||||
version_exists() {
|
||||
local version="$1"
|
||||
[ -d "${RBENV_ROOT}/versions/${version}" ]
|
||||
}
|
||||
|
||||
if [ -d "$RBENV_VERSION_PATH" ]; then
|
||||
if version_exists "$RBENV_VERSION"; then
|
||||
echo "$RBENV_VERSION"
|
||||
elif version_exists "${RBENV_VERSION#ruby-}"; then
|
||||
{ echo "warning: ignoring extraneous \`ruby-' prefix in version \`${RBENV_VERSION}'"
|
||||
echo " (set by $(rbenv-version-origin))"
|
||||
} >&2
|
||||
echo "${RBENV_VERSION#ruby-}"
|
||||
else
|
||||
echo "rbenv: version \`$RBENV_VERSION' is not installed" >&2
|
||||
exit 1
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: Explain how the current Ruby version is set
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: List all Ruby versions available to rbenv
|
||||
# Usage: rbenv versions [--bare]
|
||||
#
|
||||
# Lists all Ruby versions found in `$RBENV_ROOT/versions/*'.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
RBENV_VERSION_NAME="$(rbenv-version-name)"
|
||||
|
||||
if [ "$1" = "--bare" ]; then
|
||||
hit_prefix=""
|
||||
miss_prefix=""
|
||||
print_version="$RBENV_VERSION_NAME"
|
||||
current_version=""
|
||||
include_system=""
|
||||
else
|
||||
hit_prefix="* "
|
||||
miss_prefix=" "
|
||||
print_version="$(rbenv-version)"
|
||||
current_version="$(rbenv-version-name || true)"
|
||||
include_system="1"
|
||||
fi
|
||||
|
||||
print_version() {
|
||||
if [ "$1" == "$current_version" ]; then
|
||||
echo "${hit_prefix}$(rbenv-version 2>/dev/null)"
|
||||
else
|
||||
echo "${miss_prefix}$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Include "system" in the non-bare output, if it exists
|
||||
if [ -n "$include_system" ] && RBENV_VERSION=system rbenv-which ruby >/dev/null 2>&1; then
|
||||
print_version system
|
||||
fi
|
||||
|
||||
for path in "${RBENV_ROOT}/versions/"*; do
|
||||
if [ -d "$path" ]; then
|
||||
version="${path##*/}"
|
||||
|
||||
if [ "$version" == "$RBENV_VERSION_NAME" ]; then
|
||||
echo "${hit_prefix}${print_version}"
|
||||
else
|
||||
echo "${miss_prefix}${version}"
|
||||
fi
|
||||
print_version "${path##*/}"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Summary: List all Ruby versions that contain the given executable
|
||||
# Usage: rbenv whence [--path] <command>
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -27,7 +30,7 @@ whence() {
|
||||
|
||||
RBENV_COMMAND="$1"
|
||||
if [ -z "$RBENV_COMMAND" ]; then
|
||||
echo "usage: rbenv whence [--path] COMMAND" >&2
|
||||
rbenv-help --usage whence >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Summary: Display the full path to an executable
|
||||
#
|
||||
# Usage: rbenv which <command>
|
||||
#
|
||||
# Displays the full path to the executable that rbenv will invoke when
|
||||
# you run the given command.
|
||||
|
||||
set -e
|
||||
[ -n "$RBENV_DEBUG" ] && set -x
|
||||
|
||||
@@ -27,7 +35,10 @@ remove_from_path() {
|
||||
return
|
||||
fi
|
||||
|
||||
for path in ${PATH//:/$'\n'}; do
|
||||
local paths
|
||||
IFS=: paths=($PATH)
|
||||
|
||||
for path in "${paths[@]}"; do
|
||||
path="$(expand_path "$path" || true)"
|
||||
if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then
|
||||
result="${result}${path}:"
|
||||
@@ -41,13 +52,13 @@ RBENV_VERSION="$(rbenv-version-name)"
|
||||
RBENV_COMMAND="$1"
|
||||
|
||||
if [ -z "$RBENV_COMMAND" ]; then
|
||||
echo "usage: rbenv which COMMAND" >&2
|
||||
rbenv-help --usage which >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$RBENV_VERSION" = "system" ]; then
|
||||
PATH="$(remove_from_path "${RBENV_ROOT}/shims")"
|
||||
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND")"
|
||||
RBENV_COMMAND_PATH="$(command -v "$RBENV_COMMAND" || true)"
|
||||
else
|
||||
RBENV_COMMAND_PATH="${RBENV_ROOT}/versions/${RBENV_VERSION}/bin/${RBENV_COMMAND}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user