Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

341 lignes
12 KiB

il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
il y a 13 ans
  1. # Simple Ruby Version Management: rbenv
  2. rbenv lets you easily switch between multiple versions of Ruby. It's
  3. simple, unobtrusive, and follows the UNIX tradition of single-purpose
  4. tools that do one thing well.
  5. <img src="http://i.sstephenson.us/rbenv.png" width="894" height="464">
  6. ### rbenv _does…_
  7. * Let you **change the global Ruby version** on a per-user basis.
  8. * Provide support for **per-project Ruby versions**.
  9. * Allow you to **override the Ruby version** with an environment
  10. variable.
  11. ### In contrast with rvm, rbenv _does not…_
  12. * **Need to be loaded into your shell.** Instead, rbenv's shim
  13. approach works by adding a directory to your `$PATH`.
  14. * **Override shell commands like `cd`.** That's dangerous and
  15. error-prone.
  16. * **Have a configuration file.** There's nothing to configure except
  17. which version of Ruby you want to use.
  18. * **Install Ruby.** You can build and install Ruby yourself, or use
  19. [ruby-build](https://github.com/sstephenson/ruby-build) to
  20. automate the process.
  21. * **Manage gemsets.** [Bundler](http://gembundler.com/) is a better
  22. way to manage application dependencies. If you have projects that
  23. are not yet using Bundler you can install the
  24. [rbenv-gemset](https://github.com/jamis/rbenv-gemset) plugin.
  25. * **Require changes to Ruby libraries for compatibility.** The
  26. simplicity of rbenv means as long as it's in your `$PATH`,
  27. [nothing](https://rvm.beginrescueend.com/integration/bundler/)
  28. [else](https://rvm.beginrescueend.com/integration/capistrano/)
  29. needs to know about it.
  30. * **Prompt you with warnings when you switch to a project.** Instead
  31. of executing arbitrary code, rbenv reads just the version name
  32. from each project. There's nothing to "trust."
  33. ## Table of Contents
  34. * [1 How It Works](#section_1)
  35. * [2 Installation](#section_2)
  36. * [2.1 Upgrading an existing installation](#section_2.1)
  37. * [3 Usage](#section_3)
  38. * [3.1 rbenv global](#section_3.1)
  39. * [3.2 rbenv local](#section_3.2)
  40. * [3.3 rbenv shell](#section_3.3)
  41. * [3.4 rbenv versions](#section_3.4)
  42. * [3.5 rbenv version](#section_3.5)
  43. * [3.6 rbenv rehash](#section_3.6)
  44. * [3.7 rbenv which](#section_3.7)
  45. * [3.8 rbenv whence](#section_3.8)
  46. * [4 Development](#section_4)
  47. * [4.1 Version History](#section_4.1)
  48. * [4.2 License](#section_4.2)
  49. ## <a name="section_1"></a> 1 How It Works
  50. rbenv operates on the per-user directory `~/.rbenv`. Version names in
  51. rbenv correspond to subdirectories of `~/.rbenv/versions`. For
  52. example, you might have `~/.rbenv/versions/1.8.7-p354` and
  53. `~/.rbenv/versions/1.9.3-rc1`.
  54. Each version is a working tree with its own binaries, like
  55. `~/.rbenv/versions/1.8.7-p354/bin/ruby` and
  56. `~/.rbenv/versions/1.9.3-rc1/bin/irb`. rbenv makes _shim binaries_
  57. for every such binary across all installed versions of Ruby.
  58. These shims are simple wrapper scripts that live in `~/.rbenv/shims`
  59. and detect which Ruby version you want to use. They insert the
  60. directory for the selected version at the beginning of your `$PATH`
  61. and then execute the corresponding binary.
  62. Because of the simplicity of the shim approach, all you need to use
  63. rbenv is `~/.rbenv/shims` in your `$PATH`.
  64. ## <a name="section_2"></a> 2 Installation
  65. rbenv is a young project, so for now you must install it from source.
  66. **Compatibility note**: rbenv is _incompatible_ with rvm. Things will
  67. appear to work until you try to install a gem. The problem is that
  68. rvm actually overrides the `gem` command with a shell function!
  69. Please remove any references to rvm before using rbenv.
  70. 1. Check out rbenv into `~/.rbenv`.
  71. $ cd
  72. $ git clone git://github.com/sstephenson/rbenv.git .rbenv
  73. 2. Add `~/.rbenv/bin` to your `$PATH` for access to the `rbenv`
  74. command-line utility.
  75. $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
  76. zsh users should add this line to `.zshrc` instead:
  77. $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .zshrc
  78. 3. Add rbenv's shims directory to your `$PATH` and set up Bash
  79. autocompletion. (If you prefer not to load rbenv in your shell, you
  80. can manually add `$HOME/.rbenv/shims` to your path in step 2.)
  81. $ echo 'eval "$(rbenv init -)"' >> .bash_profile
  82. zsh users should add this line to `.zshrc` instead:
  83. $ echo 'eval "$(rbenv init -)"' >> .zshrc
  84. 4. Restart your shell so the path changes take effect. You can now
  85. begin using rbenv.
  86. $ exec $SHELL
  87. 5. Install Ruby versions into `~/.rbenv/versions`. For example, to
  88. install Ruby 1.9.2-p290, download and unpack the source, then run:
  89. $ ./configure --prefix=$HOME/.rbenv/versions/1.9.2-p290
  90. $ make
  91. $ make install
  92. The [ruby-build](https://github.com/sstephenson/ruby-build)
  93. provides an `rbenv install` command that simplifies the process of
  94. installing new Ruby versions to:
  95. $ rbenv install 1.9.2-p290
  96. 6. Rebuild the shim binaries. You should do this any time you install
  97. a new Ruby binary (for example, when installing a new Ruby version, or
  98. when installing a gem that provides a binary).
  99. $ rbenv rehash
  100. ### <a name="section_2.1"></a> 2.1 Upgrading an existing installation
  101. If you've installed rbenv using the instructions above, you can
  102. upgrade your installation at any time using git.
  103. To upgrade to the latest development version of rbenv, use `git pull`:
  104. $ cd ~/.rbenv
  105. $ git pull
  106. To upgrade to a specific release of rbenv, check out the corresponding
  107. tag:
  108. $ cd ~/.rbenv
  109. $ git fetch
  110. $ git tag
  111. v0.1.0
  112. v0.1.1
  113. v0.1.2
  114. v0.2.0
  115. $ git checkout v0.2.0
  116. ## <a name="section_3"></a> 3 Usage
  117. Like `git`, the `rbenv` command delegates to subcommands based on its
  118. first argument. The most common subcommands are:
  119. ### <a name="section_3.1"></a> 3.1 rbenv global
  120. Sets the global version of Ruby to be used in all shells by writing
  121. the version name to the `~/.rbenv/version` file. This version can be
  122. overridden by a per-project `.rbenv-version` file, or by setting the
  123. `RBENV_VERSION` environment variable.
  124. $ rbenv global 1.9.2-p290
  125. The special version name `system` tells rbenv to use the system Ruby
  126. (detected by searching your `$PATH`).
  127. When run without a version number, `rbenv global` reports the
  128. currently configured global version.
  129. ### <a name="section_3.2"></a> 3.2 rbenv local
  130. Sets a local per-project Ruby version by writing the version name to
  131. an `.rbenv-version` file in the current directory. This version
  132. overrides the global, and can be overridden itself by setting the
  133. `RBENV_VERSION` environment variable or with the `rbenv shell`
  134. command.
  135. $ rbenv local rbx-1.2.4
  136. When run without a version number, `rbenv local` reports the currently
  137. configured local version. You can also unset the local version:
  138. $ rbenv local --unset
  139. ### <a name="section_3.3"></a> 3.3 rbenv shell
  140. Sets a shell-specific Ruby version by setting the `RBENV_VERSION`
  141. environment variable in your shell. This version overrides both
  142. project-specific versions and the global version.
  143. $ rbenv shell jruby-1.6.4
  144. When run without a version number, `rbenv shell` reports the current
  145. value of `RBENV_VERSION`. You can also unset the shell version:
  146. $ rbenv shell --unset
  147. Note that you'll need rbenv's shell integration enabled (step 3 of
  148. the installation instructions) in order to use this command. If you
  149. prefer not to use shell integration, you may simply set the
  150. `RBENV_VERSION` variable yourself:
  151. $ export RBENV_VERSION=jruby-1.6.4
  152. ### <a name="section_3.4"></a> 3.4 rbenv versions
  153. Lists all Ruby versions known to rbenv, and shows an asterisk next to
  154. the currently active version.
  155. $ rbenv versions
  156. 1.8.7-p352
  157. 1.9.2-p290
  158. * 1.9.3-rc1 (set by /Users/sam/.rbenv/global)
  159. jruby-1.6.4
  160. rbx-1.2.4
  161. ree-1.8.7-2011.03
  162. ### <a name="section_3.5"></a> 3.5 rbenv version
  163. Displays the currently active Ruby version, along with information on
  164. how it was set.
  165. $ rbenv version
  166. 1.8.7-p352 (set by /Volumes/37signals/basecamp/.rbenv-version)
  167. ### <a name="section_3.6"></a> 3.6 rbenv rehash
  168. Installs shims for all Ruby binaries known to rbenv (i.e.,
  169. `~/.rbenv/versions/*/bin/*`). Run this command after you install a new
  170. version of Ruby, or install a gem that provides binaries.
  171. $ rbenv rehash
  172. ### <a name="section_3.7"></a> 3.7 rbenv which
  173. Displays the full path to the binary that rbenv will execute when you
  174. run the given command.
  175. $ rbenv which irb
  176. /Users/sam/.rbenv/versions/1.9.2-p290/bin/irb
  177. ### <a name="section_3.8"></a> 3.8 rbenv whence
  178. Lists all Ruby versions with the given command installed.
  179. $ rbenv whence rackup
  180. 1.9.3-rc1
  181. jruby-1.6.4
  182. ree-1.8.7-2011.03
  183. ## <a name="section_4"></a> 4 Development
  184. The rbenv source code is [hosted on
  185. GitHub](https://github.com/sstephenson/rbenv). It's clean, modular,
  186. and easy to understand, even if you're not a shell hacker.
  187. Please feel free to submit pull requests and file bugs on the [issue
  188. tracker](https://github.com/sstephenson/rbenv/issues).
  189. ### <a name="section_4.1"></a> 4.1 Version History
  190. **HEAD**
  191. * Renamed `rbenv set-default` to `rbenv global` and `rbenv set-local`
  192. to `rbenv local`. The `set-` commands are deprecated and will be
  193. removed in the next major release.
  194. * rbenv now uses `greadlink` on Solaris.
  195. * Added a `ruby-local-exec` command which can be used in shebangs in
  196. place of `#!/usr/bin/env ruby` to properly set the project-specific
  197. Ruby version regardless of current working directory.
  198. * Fixed an issue with `rbenv rehash` when no binaries are present.
  199. * Added support for `rbenv-sh-*` commands, which run inside the
  200. current shell instead of in a child process.
  201. * Added an `rbenv shell` command for conveniently setting the
  202. `$RBENV_VERSION` environment variable.
  203. * Added support for storing rbenv versions and shims in directories
  204. other than `~/.rbenv` with the `$RBENV_ROOT` environment variable.
  205. * Added support for debugging rbenv via `set -x` when the
  206. `$RBENV_DEBUG` environment variable is set.
  207. * Refactored the autocompletion system so that completions are now
  208. built-in to each command and shared between bash and zsh.
  209. * Added support for plugin bundles in `~/.rbenv/plugins` as documented
  210. in [issue #102](https://github.com/sstephenson/rbenv/pull/102).
  211. * Added `/usr/local/etc/rbenv.d` to the list of directories searched
  212. for rbenv hooks.
  213. * Added support for an `$RBENV_DIR` environment variable which
  214. defaults to the current working directory for specifying where rbenv
  215. searches for local version files.
  216. **0.1.2** (August 16, 2011)
  217. * Fixed rbenv to be more resilient against nonexistent entries in
  218. `$PATH`.
  219. * Made the `rbenv rehash` command operate atomically.
  220. * Modified the `rbenv init` script to automatically run `rbenv
  221. rehash` so that shims are recreated whenever a new shell is opened.
  222. * Added initial support for zsh autocompletion.
  223. * Removed the dependency on egrep for reading version files.
  224. **0.1.1** (August 14, 2011)
  225. * Fixed a syntax error in the `rbenv help` command.
  226. * Removed `-e` from the shebang in favor of `set -e` at the top of
  227. each file for compatibility with operating systems that do not
  228. support more than one argument in the shebang.
  229. **0.1.0** (August 11, 2011)
  230. * Initial public release.
  231. ### <a name="section_4.2"></a> 4.2 License
  232. (The MIT license)
  233. Copyright (c) 2011 Sam Stephenson
  234. Permission is hereby granted, free of charge, to any person obtaining
  235. a copy of this software and associated documentation files (the
  236. "Software"), to deal in the Software without restriction, including
  237. without limitation the rights to use, copy, modify, merge, publish,
  238. distribute, sublicense, and/or sell copies of the Software, and to
  239. permit persons to whom the Software is furnished to do so, subject to
  240. the following conditions:
  241. The above copyright notice and this permission notice shall be
  242. included in all copies or substantial portions of the Software.
  243. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  244. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  245. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  246. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  247. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  248. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  249. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.