
co-authored-by: Peter Zhu <peter@peterzhu.ca> co-authored-by: Stan Lo <stan001212@gmail.com>
2 KiB
Building Ruby
Quick start guide
-
Install the prerequisite dependencies for building the CRuby interpreter:
- C compiler
- autoconf - 2.67 or later
- bison - 2.0 or later
- gperf - 3.0.3 or later
- ruby - 2.7 or later
-
Install optional, recommended dependencies:
- OpenSSL/LibreSSL
- readline/editline (libedit)
- zlib
- libffi
- libyaml
- libexecinfo (FreeBSD)
-
Checkout the CRuby source code:
git clone https://github.com/ruby/ruby.git
-
Generate the configuration files and build:
./autogen.sh mkdir build && cd build # its good practice to build outside of source dir mkdir ~/.rubies # we will install to .rubies/ruby-master in our home dir ../configure --prefix="${HOME}/.rubies/ruby-master" make install
-
Run tests to confirm your build succeeded
More details
If you're interested in continuing development on Ruby, here are more details about Ruby's build to help out.
Running make scripts in parallel
To run make scripts in parallel, pass flag -j<number of processes>
. For instance,
to run tests on 8 processes, use:
make test-all -j8
Miniruby vs Ruby
Miniruby is a version of Ruby which has no external dependencies and lacks certain features. It can be useful in Ruby development because it allows for faster build times. Miniruby is built before Ruby. A functional Miniruby is required to build Ruby. To build Miniruby:
make miniruby
Debugging
You can use either lldb or gdb for debugging. Before debugging, you need to create a test.rb
with the Ruby script you'd like to run. You can use the following make targets:
make run
: Runstest.rb
using Minirubymake lldb
: Runstest.rb
using Miniruby in lldbmake gdb
: Runstest.rb
using Miniruby in gdbmake runruby
: Runstest.rb
using Rubymake lldb-runruby
: Runstest.rb
using Ruby in lldbmake gdb-runruby
: Runstest.rb
using Ruby in gdb