setting up ruby on rails environment (ubuntu + mac)

Discussion in 'General Programming Chat' started by Rushdie, Jan 2, 2012.

  1. Rushdie


    Feb 2, 2009
    Likes Received:
    i know many of you had problems with this, and i also encountered many problems with tutorials/ebooks on the net.

    im using ubuntu/mint but this should also work on mac. if you got windows i think its easy and all you need should be here:

    if you dont have linux installed i suggest programming in vmware/ubuntu or mint, cause ruby/python in windows is a misery imo.

    they would have to torture me if i had to code in windows/terminal and handle gems there ;)

    ok here we go:

    install git and curl:
    sudo apt-get install git
    sudo apt-get install curl
    here if you got Mac, download those apps and install from source(you will find docs on their site) or use this freaking mac thingy for installing apps (homebrew?)

    getting and setting up Ruby Version Manager:
    bash -s stable < <(curl -s )
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
    source .bash_profile
    rvm reload
    check if rvm is all good:
    type rvm | head -n1
    should be: rvm is a function

    if there's a problem restart your terminal and start again from source .bash_profile...

    rvm pkg install zlib
    rvm pkg install openssl
    cause your OS might not have it and rvm will not install it automatically with ruby; i think its only a problem on ubuntu, and should run fine without it on OSX, the openssl might be a problem @ mac.
    This is omitted in most tutorials and i was having a problem finding a solution for this when i was setting up ruby for the first time on linux.

    rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr
    1.9.2 is the ruby version number
    if you got any problems with 1.9.2 and it's dependencies, you can remove it with rvm remove 1.9.2 and then try again after fixing the problems

    rvm --create use [email protected]
    rvm --default use [email protected]
    defines default ruby version we will use

    gem install rails
    will install the newest version of rails

    rails -v
    a version should be echoed

    check if ruby works ok by pasteing this in the terminal:
    ruby -e 'def a;10.times{puts " "*rand(79)+"*"};end;1337.times{a;puts " "*34+"Happy New Year, BHW!";a;sleep 0.1;puts "\e[2J"}'
    gogo sublime text 2 or rubymine

    if you wish i can also explain basics of heroku and github but i think its simple and been covered well in the tutorials

    EDIT: fixed a small mistake (openssl) which will help with rails in the future

    add rvm so that it starts automatically with your session:
    cd #this goes to your home folder
    touch .bashrc
    echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc
    echo 'if [ -f "$HOME/.bashrc" ]; then source $HOME/.bashrc fi #run bashrc' >> ~/.bash_profile
    restart the terminal and rvm it should produce something

    also wont hurt to install other rvm dependencies listed in:
    rvm requirements

    im not telling you to install everything you will know what you need when you're doing more advanced stuff. for now we should be ok. another tutorial is coming.

    next part of the tutorial:
    Last edited: Jan 3, 2012