Install Ruby on FreeBSD
| Update pkg | |
| Install the ruby package | |
| ruby -v | |
| Ports alternative |
Update pkg
FreeBSD manages binary packages with pkg. Refresh its catalog first so the Ruby package details are current.
This step also confirms that pkg itself works before you install anything new.
Refresh the package catalog
sudo pkg update
Wait until the update reports that the repository catalog is done. If the network was offline, run the same command again once the connection is back.
Install the ruby package
On FreeBSD the package name carries the version, so you pick the Ruby line you want at install time:
Install Ruby
sudo pkg install ruby
Confirm the install when pkg shows the package plan. It adds the ruby and gem commands so every new terminal can use them right away.
ruby -v
Check what was installed with one short command:
Show the installed Ruby version
ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [amd64-freebsd13]
You will see the word ruby followed by the version number and build details. If the terminal reports that the command was not found, log out and log in again so the new settings take effect.
Ports alternative
An alternative to binary packages is the Ports collection, which builds software from source with custom options.
Beginners should stay with pkg because it is fast and predictable. Explore Ports later when you need special build flags or want to study how a package is assembled.
Next: Ruby in Docker
Article author: Arthur Isaev