Thursday, March 17, 2011

RUBY ON RAILS 3 TUTORIAL Learn Rails by Example

For someone who get lost on Chapter 1: From Zero to Deploy Page 12 and Page 13, below are the summary of procedures on how to install Ruby & RVM on Ubuntu OS.


Operationg System:

- Ubuntu 10.10 64x

Installing ruby:
biboyatienza:~$ ruby
    The program 'ruby' is currently not installed.  You can install it by typing:
    sudo apt-get install ruby

biboyatienza:~$ sudo apt-get install ruby
    [sudo] password for ca:
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    The following extra packages will be installed:
      libreadline5 libruby1.8 ruby1.8
    Suggested packages:
      ri ruby-dev ruby1.8-examples ri1.8
    The following NEW packages will be installed:
      libreadline5 libruby1.8 ruby ruby1.8
    0 upgraded, 4 newly installed, 0 to remove and 6 not upgraded.
    Need to get 2,005kB of archives.
    After this operation, 8,262kB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get:1 http://ph.archive.ubuntu.com/ubuntu/ maverick/main libreadline5 amd64 5.2-7build1 [147kB]
    Get:2 http://ph.archive.ubuntu.com/ubuntu/ maverick/main libruby1.8 amd64 1.8.7.299-2 [1,804kB]
    Get:3 http://ph.archive.ubuntu.com/ubuntu/ maverick/main ruby1.8 amd64 1.8.7.299-2 [32.3kB]
    Get:4 http://ph.archive.ubuntu.com/ubuntu/ maverick/main ruby all 4.5 [21.8kB]
    Fetched 2,005kB in 13s (144kB/s)                                              
    Selecting previously deselected package libreadline5.
    (Reading database ... 203399 files and directories currently installed.)
    Unpacking libreadline5 (from .../libreadline5_5.2-7build1_amd64.deb) ...
    Selecting previously deselected package libruby1.8.
    Unpacking libruby1.8 (from .../libruby1.8_1.8.7.299-2_amd64.deb) ...
    Selecting previously deselected package ruby1.8.
    Unpacking ruby1.8 (from .../ruby1.8_1.8.7.299-2_amd64.deb) ...
    Selecting previously deselected package ruby.
    Unpacking ruby (from .../apt/archives/ruby_4.5_all.deb) ...
    Processing triggers for man-db ...
    Setting up libreadline5 (5.2-7build1) ...
    Setting up libruby1.8 (1.8.7.299-2) ...
    Setting up ruby1.8 (1.8.7.299-2) ...
    Setting up ruby (4.5) ...
    Processing triggers for libc-bin ...
    ldconfig deferred processing now taking place

Installing curl:
biboyatienza:~$ sudo apt-get install curl
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    curl is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

Installing git:
biboyatienza:~$ sudo apt-get install git
    Reading package lists... Done
    Building dependency tree      
    Reading state information... Done
    The following extra packages will be installed:
      liberror-perl
    Suggested packages:
      git-doc git-arch git-cvs git-svn git-email git-daemon-run git-gui gitk
      gitweb
    The following NEW packages will be installed:
      git liberror-perl
    0 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
    Need to get 6,348kB of archives.
    After this operation, 13.1MB of additional disk space will be used.
    Do you want to continue [Y/n]? y
    Get:1 http://ph.archive.ubuntu.com/ubuntu/ maverick/main liberror-perl all 0.17-1 [23.8kB]
    Get:2 http://ph.archive.ubuntu.com/ubuntu/ maverick-updates/main git amd64 1:1.7.1-1.1ubuntu0.1 [6,324kB]
    Fetched 6,348kB in 29s (213kB/s)                                              
    Selecting previously deselected package liberror-perl.
    (Reading database ... 204149 files and directories currently installed.)
    Unpacking liberror-perl (from .../liberror-perl_0.17-1_all.deb) ...
    Selecting previously deselected package git.
    Unpacking git (from .../git_1%3a1.7.1-1.1ubuntu0.1_amd64.deb) ...
    Processing triggers for man-db ...
    Setting up liberror-perl (0.17-1) ...
    Setting up git (1:1.7.1-1.1ubuntu0.1) ...

Installing RVM:
biboyatienza:~$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100   979  100   979    0     0    640      0  0:00:01  0:00:01 --:--:--  3168
    Initialized empty Git repository in /home/ca/.rvm/src/rvm/.git/
    remote: Counting objects: 18327, done.
    remote: Compressing objects: 100% (4950/4950), done.
    remote: Total 18327 (delta 12416), reused 17745 (delta 11902)
    Receiving objects: 100% (18327/18327), 3.16 MiB | 235 KiB/s, done.
    Resolving deltas: 100% (12416/12416), done.

      RVM:  Shell scripts enabling management of multiple ruby environments.
      RTFM: http://rvm.beginrescueend.com/
      HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

    Installing RVM to /home/ca/.rvm/
        Correct permissions for base binaries in /home/ca/.rvm/bin...
        Copying manpages into place.


    Notes for Linux ( DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=10.10
    DISTRIB_CODENAME=maverick
    DISTRIB_DESCRIPTION="Ubuntu 10.10" )

    NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
          'ree'  represents Ruby Enterprise Edition
          'rbx'  represents Rubinius

    bash >= 3.2 is required
    curl is required
    git is required (>= 1.7 recommended)
    patch is required (for ree and some ruby-head's).

    If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
    then you must install and use rvm 1.8.7 first.

    If you wish to have the 'pretty colors' again,
      set 'export rvm_pretty_print_flag=1' in ~/.rvmrc.

    dependencies:
    # For RVM
      rvm: bash curl git

    # For Ruby (MRI & ree)  you should install the following OS dependencies:
      ruby: /usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev

    # For JRuby (if you wish to use it) you will need:
      jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
      jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

    # In addition to ruby: dependencies,
      ruby-head: subversion

    # For IronRuby (if you wish to use it) you will need:
      ironruby: /usr/bin/apt-get install curl mono-2.0-devel


      You must now complete the install by loading RVM in new shells.

      1) Place the folowing line at the end of your shell's loading files
         (.bashrc or .bash_profile for bash and .zshrc for zsh),
         after all PATH/variable settings:

         [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

         You only need to add this line the first time you install rvm.

      2) Ensure that there is no 'return' from inside the ~/.bashrc file,
         otherwise rvm may be prevented from working properly.

        
      This means that if you see something like:

        '[ -z "$PS1" ] && return'

      then you change this line to:

      if [[ -n "$PS1" ]] ; then

        # ... original content that was below the '&& return' line ...

      fi # <= be sure to close the if at the end of the .bashrc.

      # This is a good place to source rvm v v v
      [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

    EOF - This marks the end of the .bashrc file

         Be absolutely *sure* to REMOVE the '&& return'.

         If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.

         Placing all non-interactive (non login) items in the .bashrc,
         including the 'source' line above and any environment settings.

      3) CLOSE THIS SHELL and open a new one in order to use rvm.
     

      WARNING:  you have a 'return' statement in your ~/.bashrc
              This could cause some features of RVM to not work.

     
      This means that if you see something like:

        '[ -z "$PS1" ] && return'

      then you change this line to:

      if [[ -n "$PS1" ]] ; then

        # ... original content that was below the '&& return' line ...

      fi # <= be sure to close the if at the end of the .bashrc.

      # This is a good place to source rvm v v v
      [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

    EOF - This marks the end of the .bashrc file

      Even if you are using zsh you should still adjust the ~/.bashrc
      If you have any questions about this please visit
        #rvm on irc.freenode.net.
     

    Installation of RVM to /home/ca/.rvm/ is complete.


    biboyatienza,

    Thank you very much for using RVM! I sincerely hope that RVM helps to
    make your work both easier and more enjoyable.

    If you have any questions, issues and/or ideas for improvement please
    join#rvm on irc.freenode.net and let me know, note you must register
    (http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to
    talk, this prevents spambots from ruining our day.

    My irc nickname is 'wayneeseguin' and I hang out in #rvm typically

      ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT

    If I do not respond right away, please hang around after asking your
    question, I will respond as soon as I am back.  It is best to talk in
    #rvm itself as then other users can help out should I be offline.

    Be sure to get head often as rvm development happens fast,
    you can do this by running 'rvm get head' followed by 'rvm reload'
    or opening a new shell

      w⦿‿⦿t

        ~ Wayne

Adjust .bashrc:
biboyatienza:~$ gedit .bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.


Test RVM:
biboyatienza:~$ type rvm | head -1
rvm is a function

Installing ruby by RVM:

Source:
http://www.ruby-lang.org/en/news/2010/12/25/ruby-1-9-2-p136-is-released/

ruby-1.8.7:
biboyatienza:~$ rvm  install ruby-1.8.7-p160
    Installing Ruby from source to: /home/ca/.rvm/rubies/ruby-1.8.7-p160, this may take a while depending on your cpu(s)...

    ruby-1.8.7-p160 - #fetching
    ruby-1.8.7-p160 - #downloading ruby-1.8.7-p160, this may take a while depending on your connection...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100 4040k  100 4040k    0     0   169k      0  0:00:23  0:00:23 --:--:--  227k
    ruby-1.8.7-p160 - #extracting ruby-1.8.7-p160 to /home/ca/.rvm/src/ruby-1.8.7-p160
    ruby-1.8.7-p160 - #extracted to /home/ca/.rvm/src/ruby-1.8.7-p160
    ruby-1.8.7-p160 - #configuring
    ruby-1.8.7-p160 - #compiling
    ruby-1.8.7-p160 - #installing
    ruby-1.8.7-p160 - #rubygems installing to ruby-1.8.7-p160
    Retrieving rubygems-1.6.2
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100  236k  100  236k    0     0  32570      0  0:00:07  0:00:07 --:--:-- 57769
    Extracting rubygems-1.6.2 ...
    ruby-1.8.7-p160 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
    ruby-1.8.7-p160 - #importing default gemsets (/home/ca/.rvm/gemsets/)
    Install of ruby-1.8.7-p160 - #complete

ruby-1.9.2:
biboyatienza:~$ rvm  install ruby-1.9.2-p136
    Installing Ruby from source to: /home/ca/.rvm/rubies/ruby-1.9.2-p136, this may take a while depending on your cpu(s)...

    ruby-1.9.2-p136 - #fetching
    ruby-1.9.2-p136 - #downloading ruby-1.9.2-p136, this may take a while depending on your connection...
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
    100 8612k  100 8612k    0     0   198k      0  0:00:43  0:00:43 --:--:--  144k
    100 8612k  100 8612k    0     0   197k      0  0:00:43  0:00:43 --:--:--  197kruby-1.9.2-p136 - #extracting ruby-1.9.2-p136 to /home/ca/.rvm/src/ruby-1.9.2-p136
    ruby-1.9.2-p136 - #extracted to /home/ca/.rvm/src/ruby-1.9.2-p136
    ruby-1.9.2-p136 - #configuring
    ruby-1.9.2-p136 - #compiling
    ruby-1.9.2-p136 - #installing
    ruby-1.9.2-p136 - Updating #rubygems to the latest.
    Removing old Rubygems files...
    Installing rubygems dedicated to ruby-1.9.2-p136...
    Installing rubygems for /home/ca/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
    Installation of rubygems completed successfully.
    ruby-1.9.2-p136 - Updating #rubygems to the latest.
    Removing old Rubygems files...
    Installing rubygems dedicated to ruby-1.9.2-p136...
    Installing rubygems for /home/ca/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
    Installation of rubygems completed successfully.
    ruby-1.9.2-p136 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
    ruby-1.9.2-p136 - #importing default gemsets (/home/ca/.rvm/gemsets/)
    Install of ruby-1.9.2-p136 - #complete

No comments:

Post a Comment