The object-oriented programming language is available as a port on
FreeBSD. Ruby combines syntax inspired by Perl with Smalltalk-like
features and is influenced by Eiffel and Lisp as well. With Ruby you can
make use of multiple programming paradigms, including functional,
object oriented, imperative and reflective. The automatic memory
management and a dynamic type system are one of the main key factors to
use Ruby.
Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.
Install Ruby 1.8
With the following commands you will install Ruby 1.8 from the ports directory:
cd /usr/ports/lang/ruby18/
make install clean; rehash
At this point Ruby 1.8 is installed. If you want to use a newer version, RVM can help you. This tutorial also explains how to install the RVM manager.
Install Curl
Install Curl for later use.
cd /usr/ports/ftp/curl
make install clean; rehash
Install Bash
Bash is needed to use Ruby properly.
cd /usr/ports/shells/bash
make install clean; rehash
Install Git
The following commands will install Git:
cd /usr/ports/devel/git
make install clean; rehash
Create a user
Add a new user for your Ruby environment.
adduser
Username: rvm
Full name: Ruby Version Manager
Uid (Leave empty for default):
Login group [rvm]:
Login group is rvm. Invite rvm into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash nologin) [sh]: bash
Home directory [/home/rvm]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]: no
Lock out the account after creation? [no]: no
Username : rvm
Password :
Full Name : Ruby Version Manager
Uid : 1001
Class :
Groups : rvm
Home : /home/rvm
Home Mode :
Shell : /usr/local/bin/bash
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (rvm) to the user database.
Log in as user
Log in with the newly created user (rvm) to install Ruby in this environment.
su rvm
Install RVM
The following command will install the RVM manager:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Downloading RVM from wayneeseguin branch stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 796k 100 796k 0 0 941k 0 --:--:-- --:--:-- --:--:-- 4490k
Installing RVM to /home/rvm/.rvm/
installing - /home/rvm/.rvm/man/man1/rvm.1 -
installing - /home/rvm/.rvm/man/man1/rvm.1.gz -
# RVM: Shell scripts enabling management of multiple ruby environments.
# RTFM: https://rvm.beginrescueend.com/
# HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)
# Screencast: http://screencasts.org/episodes/how-to-use-rvm
# In case of any issues read output of 'rvm requirements' and/or 'rvm notes'
Installation of RVM in /home/rvm/.rvm/ is almost complete:
* To start using RVM you need to run `source /home/rvm/.bashrc`
in all your open shell windows, in rare cases you need to reopen all shell windows.
# rvm,
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne
Load RVM at login
Type these commands into the console to start RVM at login:
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
Reload Bash profile
Reload your Bash profile so that the previous changes can take effect.
source ~/.bash_profile
Check that all is OK
Receiving an other response than
rvm is a function means that RVM is not loaded.
type rvm | head -1
rvm is a function
List available Ruby versions
Now, you can list the available Ruby versions with the following command:
rvm list known
Install Ruby
Install your favorite Ruby version.
rvm install 1.9.3-head
Set the default Ruby version
Set the just installed Ruby version as default.
rvm use 1.9.3-head --default
Check your installed Ruby version
Check your Ruby version with this command:
ruby -v