• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H23-Mar-2022-10588

bin/H23-Mar-2022-1,8021,395

script/H23-Mar-2022-368283

share/ruby-build/H23-Mar-2022-2,3981,848

test/H23-Mar-2022-2,2021,690

.gitignoreH A D23-Mar-20226 21

CODE_OF_CONDUCT.mdH A D23-Mar-20223.3 KiB8160

CONTRIBUTING.mdH A D23-Mar-202298 42

LICENSEH A D23-Mar-20221 KiB2016

README.mdH A D23-Mar-20227.8 KiB169124

install.shH A D23-Mar-2022357 2110

README.md

1# ruby-build
2
3ruby-build is a command-line utility that makes it easy to install virtually any
4version of Ruby, from source.
5
6It is available as a plugin for [rbenv][] that
7provides the `rbenv install` command, or as a standalone program.
8
9## Installation
10
11```sh
12# Using Homebrew on macOS
13$ brew install ruby-build
14
15# As an rbenv plugin
16$ mkdir -p "$(rbenv root)"/plugins
17$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
18
19# As a standalone program
20$ git clone https://github.com/rbenv/ruby-build.git
21$ PREFIX=/usr/local ./ruby-build/install.sh
22```
23
24### Upgrading
25
26```sh
27# Via Homebrew
28$ brew update && brew upgrade ruby-build
29
30# As an rbenv plugin
31$ git -C "$(rbenv root)"/plugins/ruby-build pull
32```
33
34## Usage
35
36### Basic Usage
37
38```sh
39# As an rbenv plugin
40$ rbenv install --list                 # lists all available versions of Ruby
41$ rbenv install 2.2.0                  # installs Ruby 2.2.0 to ~/.rbenv/versions
42
43# As a standalone program
44$ ruby-build --definitions             # lists all available versions of Ruby
45$ ruby-build 2.2.0 ~/local/ruby-2.2.0  # installs Ruby 2.2.0 to ~/local/ruby-2.2.0
46```
47
48ruby-build does not check for system dependencies before downloading and
49attempting to compile the Ruby source. Please ensure that [all requisite
50libraries][build-env] are available on your system.
51
52### Advanced Usage
53
54#### Custom Build Definitions
55
56If you wish to develop and install a version of Ruby that is not yet supported
57by ruby-build, you may specify the path to a custom “build definition file” in
58place of a Ruby version number.
59
60Use the [default build definitions][definitions] as a template for your custom
61definitions.
62
63#### Custom Build Configuration
64
65The build process may be configured through the following environment variables:
66
67| Variable                        | Function                                                                                         |
68| ------------------------------- | ------------------------------------------------------------------------------------------------ |
69| `TMPDIR`                        | Where temporary files are stored.                                                                |
70| `RUBY_BUILD_BUILD_PATH`         | Where sources are downloaded and built. (Default: a timestamped subdirectory of `TMPDIR`)        |
71| `RUBY_BUILD_CACHE_PATH`         | Where to cache downloaded package files. (Default: `~/.rbenv/cache` if invoked as rbenv plugin)  |
72| `RUBY_BUILD_HTTP_CLIENT`        | One of `aria2c`, `curl`, or `wget` to use for downloading. (Default: first one found in PATH)    |
73| `RUBY_BUILD_ARIA2_OPTS`         | Additional options to pass to `aria2c` for downloading.                                          |
74| `RUBY_BUILD_CURL_OPTS`          | Additional options to pass to `curl` for downloading.                                            |
75| `RUBY_BUILD_WGET_OPTS`          | Additional options to pass to `wget` for downloading.                                            |
76| `RUBY_BUILD_MIRROR_URL`         | Custom mirror URL root.                                                                          |
77| `RUBY_BUILD_MIRROR_PACKAGE_URL` | Custom complete mirror URL (e.g. http://mirror.example.com/package-1.0.0.tar.gz).                  |
78| `RUBY_BUILD_SKIP_MIRROR`        | Bypass the download mirror and fetch all package files from their original URLs.                 |
79| `RUBY_BUILD_ROOT`               | Custom build definition directory. (Default: `share/ruby-build`)                                 |
80| `RUBY_BUILD_DEFINITIONS`        | Additional paths to search for build definitions. (Colon-separated list)                         |
81| `CC`                            | Path to the C compiler.                                                                          |
82| `RUBY_CFLAGS`                   | Additional `CFLAGS` options (_e.g.,_ to override `-O3`).                                         |
83| `CONFIGURE_OPTS`                | Additional `./configure` options.                                                                |
84| `MAKE`                          | Custom `make` command (_e.g.,_ `gmake`).                                                         |
85| `MAKE_OPTS` / `MAKEOPTS`        | Additional `make` options.                                                                       |
86| `MAKE_INSTALL_OPTS`             | Additional `make install` options.                                                               |
87| `RUBY_CONFIGURE_OPTS`           | Additional `./configure` options (applies only to Ruby source).                                  |
88| `RUBY_MAKE_OPTS`                | Additional `make` options (applies only to Ruby source).                                         |
89| `RUBY_MAKE_INSTALL_OPTS`        | Additional `make install` options (applies only to Ruby source).                                 |
90
91#### Applying Patches
92
93Both `rbenv install` and `ruby-build` support the `--patch` (`-p`) flag to apply
94a patch to the Ruby (/JRuby/Rubinius/TruffleRuby) source code before building.
95Patches are read from `STDIN`:
96
97```sh
98# applying a single patch
99$ rbenv install --patch 1.9.3-p429 < /path/to/ruby.patch
100
101# applying a patch from HTTP
102$ rbenv install --patch 1.9.3-p429 < <(curl -sSL http://git.io/ruby.patch)
103
104# applying multiple patches
105$ cat fix1.patch fix2.patch | rbenv install --patch 1.9.3-p429
106```
107
108#### Checksum Verification
109
110If you have the `shasum`, `openssl`, or `sha256sum` tool installed, ruby-build will
111automatically verify the SHA2 checksum of each downloaded package before
112installing it.
113
114Checksums are optional and specified as anchors on the package URL in each
115definition. All definitions bundled with ruby-build include checksums.
116
117#### Package Mirrors
118
119To speed up downloads, ruby-build fetches package files from a mirror hosted on
120Amazon CloudFront. To benefit from this, the packages must specify their checksum:
121
122```sh
123# example:
124install_package "ruby-2.6.5" "https://ruby-lang.org/ruby-2.6.5.tgz#<SHA2>"
125```
126
127ruby-build will first try to fetch this package from `$RUBY_BUILD_MIRROR_URL/<SHA2>`
128(note: this is the complete URL), where `<SHA2>` is the checksum for the file. It
129will fall back to downloading the package from the original location if:
130- the package was not found on the mirror;
131- the mirror is down;
132- the download is corrupt, i.e. the file's checksum doesn't match;
133- no tool is available to calculate the checksum; or
134- `RUBY_BUILD_SKIP_MIRROR` is enabled.
135
136You may specify a custom mirror by setting `RUBY_BUILD_MIRROR_URL`.
137
138If a mirror site doesn't conform to the above URL format, you can specify the
139complete URL by setting `RUBY_BUILD_MIRROR_PACKAGE_URL`. It behaves the same as
140`RUBY_BUILD_MIRROR_URL` except being a complete URL.
141
142The default ruby-build download mirror is sponsored by
143[Basecamp](https://basecamp.com/).
144
145#### Keeping the build directory after installation
146
147Both `ruby-build` and `rbenv install` accept the `-k` or `--keep` flag, which
148tells ruby-build to keep the downloaded source after installation. This can be
149useful if you need to use `gdb` and `memprof` with Ruby.
150
151Source code will be kept in a parallel directory tree `~/.rbenv/sources` when
152using `--keep` with the `rbenv install` command. You should specify the
153location of the source code with the `RUBY_BUILD_BUILD_PATH` environment
154variable when using `--keep` with `ruby-build`.
155
156## Getting Help
157
158Please see the [ruby-build wiki][wiki] for solutions to common problems.
159
160If you can't find an answer on the wiki, open an issue on the [issue tracker][].
161Be sure to include the full build log for build failures.
162
163
164  [rbenv]: https://github.com/rbenv/rbenv
165  [definitions]: https://github.com/rbenv/ruby-build/tree/master/share/ruby-build
166  [wiki]: https://github.com/rbenv/ruby-build/wiki
167  [build-env]: https://github.com/rbenv/ruby-build/wiki#suggested-build-environment
168  [issue tracker]: https://github.com/rbenv/ruby-build/issues
169