# Before there were Slackware packages for Ruby, this howto used to use
# the configure script's defaults (/usr/local) for installing Ruby, but
# now it puts it in /usr to match where Slackware puts it - so we don't
# break things that use Ruby. If you have a /usr/local installed copy
# of Ruby, run something like "find /usr/local | grep ruby" and zap all
# of that.
# If you want to remove _everything_ from Ruby in /usr and /usr/local,
# skip down to the bottom. That (in /usr) will include things that
# KDE packages put there.
# Get the tarball
cd
test -f installed/ruby-3.4.2.tar.xz &&
mv installed/ruby-3.4.2.tar.xz .
test ! -f ruby-3.4.2.tar.xz &&
wget https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.2.tar.xz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "ruby-*" -exec rm -r {} \;
tar xJvf ~/ruby-3.4.2.tar.xz
cd ruby-3.4.2
test $UID = 0 && chown -R root:root .
# Create a build directory
mkdir -p build && cd build
# If you don't want/need the rdoc indexes or API docs:
# --disable-install-doc
# If you don't want/need the rdoc indexes:
# --disable-install-rdoc
# If you don't want/need the C API docs:
# --disable-install-capi
# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
../configure --prefix=/usr --datadir=/usr/share --docdir=/usr/doc/ruby \
--libdir=/usr/lib64 --mandir=/usr/man --enable-shared
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
../configure --prefix=/usr --datadir=/usr/share --docdir=/usr/doc/ruby \
--mandir=/usr/man --enable-shared
# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg ruby
# Install it
make install
ldconfig
## If you are low on disk space, after confirming that they are not in use
## by a running daemon (lsof), clean up old version files in these locations:
# cat .installed.list | sort | less
# Ruby gems...
# https://guides.rubygems.org
#
# To confirm paths, run 'gem environment' as your non-root user
#
# If you install gems system-wide as root, they will be in
# /usr/lib*/ruby/gems/3.4.0/gems/ with binaries in /usr/bin
# /usr/bin is already in your PATH, so that's it.
# gem install gemname
# ...though installing gems system-wide is frowned upon.
#
# If you will be installing gems as a user, not system wide,
# the binaries will be in /home/username/.local/share/gem/ruby/3.4.0/bin/
# gem install --user-install gemname
#
# Gems used to go in to ~/.gem with earlier versions of Ruby. If you do not
# have a .gem, you could certainly maintain a version-less symlink every
# time you upgrade such as ~/.local/share/gem/ruby/3.4.0 -> ~/.gem
# to make that shorter and then only need to add ~/.gem/bin to your PATH.
#
# With user installs, you need to add that directory to that user's PATH.
# How to do that depends on the .*rc files that you have, but it would
# normally be .bashrc or .bash_login or .bash_profile or .profile You can
# also create a /etc/profile.d/ruby-gems.sh to update every user's PATH at
# login, if that directory exists for them. The root user and any other
# user would need to install the gem separately.
cat << EOF > /etc/profile.d/ruby-gems.sh
#!/bin/sh
if [ -d "\${HOME}/.local/share/gem/ruby/3.4.0/bin" ]; then
PATH="\${PATH}:\${HOME}/.local/share/gem/ruby/3.4.0/bin"
fi
export PATH
EOF
chmod +x /etc/profile.d/ruby-gems.sh
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root self again
exit
# To read Ruby-related info:
# Run 'man ruby'
# Run 'ri'
# Go to the Ruby web site (link at the top)
# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/ruby-*.tar.*
mv ruby-3.4.2.tar.xz installed/
# If you ever want to uninstall Ruby, this should do it:
# (see ~/src/ruby-3.4.2/build/.installed.list)
cd
su
cd src/ruby-3.4.2/build
make uninstall
for pfx in /usr /usr/local;
do
( cd ${pfx}/bin
rm -f bundle bundler erb gem irb racc rake rbs rdbg rdoc ri ruby \
syntax_suggest testrb typeprof )
find ${pfx}/include -type d -maxdepth 1 -name "ruby-*" -exec rm -r {} \;
test -d ${pfx}/lib/ruby && rm -r ${pfx}/lib/ruby
test -d ${pfx}/lib/ruby_lib && rm -r ${pfx}/lib/ruby_lib
rm -f ${pfx}/lib/libruby-static.a ${pfx}/man/man1/ruby.1
done
exit
find ~/src -maxdepth 1 -type d -name "ruby-*" -exec rm -r {} \;
rm -f ~/installed/ruby-*.tar.*