1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

setting up ruby on rails environment (ubuntu + mac)

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

  1. Rushdie

    Rushdie BANNED BANNED

    Joined:
    Feb 2, 2009
    Messages:
    1,378
    Likes Received:
    1,720
    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:
    http://rubyonrails.org/download

    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:
    Code:
    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:
    Code:
    bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
    
    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:
    Code:
    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...

    [edit]
    dependency:
    Code:
    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.


    ruby:
    Code:
    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
    [/edit]

    Code:
    rvm --create use 1.9.2@default
    rvm --default use 1.9.2@default
    defines default ruby version we will use

    rails:
    Code:
    gem install rails
    will install the newest version of rails

    Code:
    rails -v
    a version should be echoed

    check if ruby works ok by pasteing this in the terminal:
    Code:
    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

    ALSO:
    add rvm so that it starts automatically with your session:
    Code:
    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.

    edit:
    next part of the tutorial: http://www.blackhatworld.com/blackhat-seo/general-programming-chat/389961-ruby-rails-tutorial-setting-up-github-heroku-deploying-sample-application.html
     
    Last edited: Jan 3, 2012