Installing dRuby: the drb gem and Ruby 3.4
drb was a default library and became a bundled gem in Ruby 3.4. When you need gem "drb" in your Gemfile and how to check it loads.
Updated
On most Ruby installations there is nothing to install: require 'drb/drb' just works. The one thing to know is that drb changed from a default gem to a bundled gem in Ruby 3.4, so a project that uses Bundler must now list it in its Gemfile.
What changed in Ruby 3.4
Ruby ships two kinds of standard library gems:
- Default gems are part of Ruby itself and can always be required.
- Bundled gems are installed alongside Ruby, but behave like ordinary gems. Under Bundler they are only available if the Gemfile asks for them.
drb was a default gem through Ruby 3.3 and is a bundled gem from Ruby 3.4. Ruby 3.3 prints a warning when drb is loaded under Bundler without being declared, to give projects time to prepare.
With Bundler
Add drb to your Gemfile:
# Gemfile
source 'https://rubygems.org'
gem 'drb'
Then run bundle install. Declaring the gem is harmless on older Ruby versions too, so it is the simplest way to support several versions at once.
If you use Rinda, declare it as well. The rinda library made the same move from default gem to bundled gem in Ruby 3.4:
gem 'drb'
gem 'rinda'
Without Bundler
A plain script run with ruby server.rb does not need a Gemfile. Bundled gems are installed with Ruby, so require 'drb/drb' continues to work. If your Ruby was packaged without its bundled gems, install it yourself:
gem install drb
Checking that it loads
require 'drb/drb'
DRb.start_service
puts DRb.uri
DRb.stop_service
This starts a dRuby server on a free port, prints its URI (something like druby://yourhost:54321) and stops it again. If you see a LoadError instead, drb is missing from your Gemfile or was not installed with your Ruby.
Which file to require
| Require | What you get |
|---|---|
drb/drb |
The core library: DRb, DRbObject, DRbUndumped |
drb |
The same core, loaded through a short wrapper |
drb/acl |
Access control lists, see ACLs |
drb/unix |
The drbunix: protocol for UNIX domain sockets |
drb/ssl |
The drbssl:// protocol |
The protocols are explained on URIs and protocols.
Next
Once the check above prints a URI, move on to a first server and client.