How to install ruby & rubygems in Alpine Linux
Problem:
You want to install ruby
and the gem
package manager in Alpine linux, but running apk install ruby rubygems
shows you that the package doesn’t exist
/ # apk add ruby rubygems
ERROR: unable to select packages:
rubygems (no such package):
required by: world[rubygems]
Solution
gem
is included in the ruby
package. So the only command you need to run is
apk update
apk add ruby
Example output:
/ # apk add ruby
(1/7) Installing ca-certificates (20191127-r5)
(2/7) Installing gdbm (1.19-r0)
(3/7) Installing gmp (6.2.1-r0)
(4/7) Installing readline (8.1.0-r0)
(5/7) Installing yaml (0.2.5-r0)
(6/7) Installing ruby-libs (2.7.3-r0)
(7/7) Installing ruby (2.7.3-r0)
Executing busybox-1.32.1-r6.trigger
Executing ca-certificates-20191127-r5.trigger
OK: 928 MiB in 154 packages
After doing that, you can immediately use both ruby
and gem
.