2013年8月8日木曜日

Which Version Should I Use on Mac? 1.8, 1.9 or 2.0? And How?

Here are comparisons between 1.8 and 1.9 as well as 1.9 and 2.0.

  • http://stackoverflow.com/questions/21574/what-is-the-difference-between-ruby-1-8-and-ruby-1-9
  • http://stackoverflow.com/questions/15799687/what-are-the-major-differences-between-ruby-1-9-3-and-ruby-2-0-0

Version 2.0 looks fine. Also, Rails4's primary target of ruby version is 2.0. One small caveat is most ruby books have not yet revised for 2.0. But the differences between 1.9.3 and 2.0.0 is so small and that won't hurt learning process. Okay. Let's go with 2.0.

Next. How? I've found an informative blog entry about this.

  • http://www.moncefbelyamani.com/how-to-install-xcode-homebrew-git-rvm-ruby-on-mac/#step-1

So, I'd like to put here a journal of what I did on my mac (MBP15, OSX10.8.4) following above entry.

  • Download and Install the Command Line Tools via Xcode
    • I had Xcode in my mac ,so followed only the procedures to install CLT via Xcode.

  • Fix Homebrew errors and warnings, and update
    • I have Homebrew but don't use it on a daily basis. So, firstly check and fix current errors and warnings with brew doctor.
      $ brew doctor
      Warning: You have uncommitted modifications to Homebrew
      If this a surprise to you, then you should stash these modifications.
      Stashing returns Homebrew to a pristine state but can be undone
      should you later need to do so for some reason.
          cd /usr/local/Library && git stash && git clean -d -f
      
      Warning: /usr/bin occurs before /usr/local/bin
      This means that system-provided programs will be used instead of those
      provided by Homebrew. The following tools exist at both paths:
      
          git
          git-cvsserver
          git-receive-pack
          git-shell
          git-upload-archive
          git-upload-pack
      
      Consider amending your PATH so that /usr/local/bin
      occurs before /usr/bin in your PATH.
      
      Warning: Your Homebrew is outdated.
      You haven't updated for at least 24 hours, this is a long time in brewland!
      To update Homebrew, run `brew update`.
      $
    • Secondly, fix them.
      1. Uncommitted modification problem
        $ cd /usr/local/Library && git stash && git clean -d -f
        cd /usr/local/Library && git stash && git clean -d -f
        No local changes to save
        Removing Aliases/fsa
        Removing Aliases/omake
        Removing Contributions/cmds/
        Removing Contributions/install_homebrew.rb
        Removing Formula/abyss.rb
        Removing Formula/blast.rb
        Removing Formula/bowtie.rb
        Removing Formula/bwa.rb
        Removing Formula/chmox.rb
        Removing Formula/cliweather.rb
        Removing Formula/clojure-contrib.rb
        Removing Formula/clustal-w.rb
        Removing Formula/cufflinks.rb
        Removing Formula/dia.rb
        Removing Formula/emboss.rb
        Removing Formula/fast-statistical-alignment.rb
        Removing Formula/fastx_toolkit.rb
        Removing Formula/gmap-gsnap.rb
        Removing Formula/gmock.rb
        Removing Formula/haxe.rb
        Removing Formula/hmmer.rb
        Removing Formula/knife-completion.rb
        Removing Formula/libpar2.rb
        Removing Formula/mira.rb
        Removing Formula/mod_python.rb
        Removing Formula/mod_wsgi.rb
        Removing Formula/mosh.rb
        Removing Formula/mosml.rb
        Removing Formula/mrfast.rb
        Removing Formula/muscle.rb
        Removing Formula/netsed.rb
        Removing Formula/o-make.rb
        Removing Formula/paml.rb
        Removing Formula/phyml.rb
        Removing Formula/plink.rb
        Removing Formula/primer3.rb
        Removing Formula/prodigal.rb
        Removing Formula/quickfix.rb
        Removing Formula/quicktree.rb
        Removing Formula/rails-completion.rb
        Removing Formula/rats.rb
        Removing Formula/samtools.rb
        Removing Formula/staticrouted.rb
        Removing Formula/synergy.rb
        Removing Formula/tabix.rb
        Removing Formula/tophat.rb
        Removing Formula/transcode.rb
        Removing Formula/uif2iso.rb
        Removing Formula/velvet.rb
        Removing Formula/vimeo-downloader.rb
        Removing Formula/xaw3d.rb
        Removing Formula/xml2rfc.rb
        Removing Homebrew/pkgconfig/
        Removing Homebrew/test/test_external_deps.rb
        Removing Homebrew/vendor/multi_json/
        $ 
      2. Path problem. At the time of install, Homebrew appended /usr/local/bin at the end of /etc/paths. So, it's a little bit strange for brew doctor to warn up the order problem. Anyway, one way to fix this problem is change the order of paths in /etc/paths but you shouldn't. It affects command selection system-widely. You should modify something bound to more smaller part of your system such as your account or your programming environment like shell or emacs.

        Let's begin with shell. There are three famous configuration file for shell which are loaded when a shell starts: .profile, .bash_profile and .bashrc. Here is a stack overflow entry that explains the difference between them.
        • http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment

        Okay. Editing $PATH in .bashrc with "if [ -f ~/.bashrc ]; then; source ~/.bashrc; fi" in .bash_profile sounds good as my start point. I created .bash_profile and added "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" at the end of my .bashrc.

        Next. Emacs. I already have
        (defun set-exec-path-from-shell-PATH ()
          "Sets the exec-path to the same value used by the user shell"
          (let ((path-from-shell
          (replace-regexp-in-string
           "[[:space:]\n]*$" ""
           (shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
            (setenv "PATH" path-from-shell)
            (setq exec-path (split-string path-from-shell path-separator))))
        
        ;; call function now
        (set-exec-path-from-shell-PATH)
        in my emacs init file, which sync the emac's exec-path and PATH automatically.
      3. Outdated problem.
        $ brew update
        

    • Thirdly, recheck my Homebrew.
      $ brew doctor
      Your system is ready to brew.
      $ 
      

  • Update git.
    $ which git
    /usr/local/bin/git
    $ git --version
    git version 1.8.1.2
    $ brew update
    Already up-to-date.
    git-crypt     git-gerrit  git-url-sub     topgit
    $ brew info git
    git: stable 1.8.3.4, HEAD
    http://git-scm.com
    /usr/local/Cellar/git/1.8.1.2 (1286 files, 182M)
    /usr/local/Cellar/git/1.8.3.4 (1327 files, 29M) *
      Built from source
    From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/git.rb
    ==> Dependencies
    Optional: pcre, gettext
    ==> Options
    --with-blk-sha1
     Compile with the block-optimized SHA1 implementation
    --with-gettext
     Build with gettext support
    --with-pcre
     Build with pcre support
    --without-completions
     Disable bash/zsh completions from "contrib" directory
    ==> Caveats
    The OS X keychain credential helper has been installed to:
      /usr/local/bin/git-credential-osxkeychain
    
    The 'contrib' directory has been installed to:
      /usr/local/share/git-core/contrib
    
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    
    zsh completion has been installed to:
      /usr/local/share/zsh/site-functions
    $ brew upgrade git
    ==> Upgrading 1 outdated package, with result:
    git 1.8.3.4
    ==> Upgrading git
    ==> Downloading http://git-core.googlecode.com/files/git-1.8.3.4.tar.gz
    ######################################################################### 100.0%
    ==> make prefix=/usr/local/Cellar/git/1.8.3.4 CC=cc CFLAGS= LDFLAGS= install
    ==> make CC=cc CFLAGS= LDFLAGS=
    ==> make clean
    ==> make CC=cc CFLAGS= LDFLAGS=
    ==> Downloading http://git-core.googlecode.com/files/git-manpages-1.8.3.4.tar.gz
    ######################################################################### 100.0%
    ==> Downloading http://git-core.googlecode.com/files/git-htmldocs-1.8.3.4.tar.gz
    ######################################################################### 100.0%
    ==> Caveats
    The OS X keychain credential helper has been installed to:
      /usr/local/bin/git-credential-osxkeychain
    
    The 'contrib' directory has been installed to:
      /usr/local/share/git-core/contrib
    
    Bash completion has been installed to:
      /usr/local/etc/bash_completion.d
    
    zsh completion has been installed to:
      /usr/local/share/zsh/site-functions
    Warning: Could not link git. Unlinking...
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    You can try again using `brew link git'
    
    Possible conflicting files are:
    /usr/local/share/zsh/site-functions/git-completion.bash -> /usr/local/Cellar/git/1.8.1.2/share/zsh/site-functions/git-completion.bash
    ==> Summary
     /usr/local/Cellar/git/1.8.3.4: 1327 files, 29M, built in 72 seconds
    $ brew link git
    Linking /usr/local/Cellar/git/1.8.3.4... Warning: Could not link git. Unlinking...
    
    Error: Could not symlink file: /usr/local/Cellar/git/1.8.3.4/share/zsh/site-functions/git-completion.bash
    Target /usr/local/share/zsh/site-functions/git-completion.bash already exists. You may need to delete it.
    To force the link and overwrite all other conflicting files, do:
      brew link --overwrite formula_name
    
    To list all files that would be deleted:
      brew link --overwrite --dry-run formula_name
    $ brew link --overwrite --dry-run git
    Would remove:
    /usr/local/share/zsh/site-functions/git-completion.bash -> /usr/local/Cellar/git/1.8.1.2/share/zsh/site-functions/git-completion.bash
    
    $ brew link --overwrite git
    Linking /usr/local/Cellar/git/1.8.3.4... 218 symlinks created
    $ which git
    /usr/local/bin/git
    $ git --version
    git version 1.8.3.4
    $ 
    
  • Install ruby and rails.
    $ curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enable
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   184  100   184    0     0     37      0  0:00:04  0:00:04 --:--:--   202
    100 13784  100 13784    0     0   1944      0  0:00:07  0:00:07 --:--:--  7976
    Please read and follow further instructions.
    Press ENTER to continue.
    Downloading RVM from wayneeseguin branch stable
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   124  100   124    0     0     63      0  0:00:01  0:00:01 --:--:--   147
    100 1081k  100 1081k    0     0   110k      0  0:00:09  0:00:09 --:--:--  219k
    
    Installing RVM to /Users/aka/.rvm/
        Adding rvm PATH line to /Users/aka/.bashrc /Users/aka/.zshrc.
    Aka  Adding rvm loading line to /Users/aka/.bash_profile /Users/aka/.zprofile.
    Installation of RVM in /Users/aka/.rvm/ is almost complete:
    
      * To start using RVM you need to run `source /Users/aka/.rvm/scripts/rvm`
        in all your open shell windows, in rare cases you need to reopen all shell windows.
    
    # Aka,
    #
    #   Thank you for using RVM!
    #   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
    #
    # ~Wayne
    
    # In case of problems:
    #      run and read: rvm notes
    #         read docs: http://rvm.io/
    #        talk to us: http://webchat.freenode.net/?channels=rvm (http://freenode.net/faq.shtml#plusr)
    #   read cheatsheet: http://cheat.errtheblog.com/s/rvm
    #  watch screencast: http://screencasts.org/episodes/how-to-use-rvm
    # open a bug report: https://github.com/wayneeseguin/rvm/issues
    
    rvm 1.21.18 (stable) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]
    
    Searching for binary rubies, this might take some time.
    Installing requirements for osx, might require sudo password.
    Already up-to-date.
    Installing required packages: automake, libtool, pkg-config, libyaml, readline, libksba, openssl...................................................................................
    Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
    Requirements installation successful.
    ruby-2.0.0-p247 - #configure
    ruby-2.0.0-p247 - #download
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 5899k  100 5899k    0     0   212k      0  0:00:27  0:00:27 --:--:--  222k
    ruby-2.0.0-p247 - #validate archive
    ruby-2.0.0-p247 - #extract
    ruby-2.0.0-p247 - #validate binary
    ruby-2.0.0-p247 - #setup
    Saving wrappers to '/Users/aka/.rvm/wrappers/ruby-2.0.0-p247'........
    ruby-2.0.0-p247 - #importing default gemsets, this may take time.......................
    Creating alias default for ruby-2.0.0-p247.
    Recording alias default for ruby-2.0.0-p247.
    Creating default links/files
    Saving wrappers to '/Users/aka/.rvm/bin'........
    Fetching: i18n-0.6.4.gem (100%)
    Successfully installed i18n-0.6.4
    Fetching: multi_json-1.7.8.gem (100%)
    Successfully installed multi_json-1.7.8
    Fetching: tzinfo-0.3.37.gem (100%)
    Successfully installed tzinfo-0.3.37
    Fetching: minitest-4.7.5.gem (100%)
    Successfully installed minitest-4.7.5
    Fetching: atomic-1.1.12.gem (100%)
    Building native extensions.  This could take a while...
    Successfully installed atomic-1.1.12
    Fetching: thread_safe-0.1.2.gem (100%)
    Successfully installed thread_safe-0.1.2
    Fetching: activesupport-4.0.0.gem (100%)
    Successfully installed activesupport-4.0.0
    Fetching: builder-3.1.4.gem (100%)
    Successfully installed builder-3.1.4
    Fetching: rack-1.5.2.gem (100%)
    Successfully installed rack-1.5.2
    Fetching: rack-test-0.6.2.gem (100%)
    Successfully installed rack-test-0.6.2
    Fetching: erubis-2.7.0.gem (100%)
    Successfully installed erubis-2.7.0
    Fetching: actionpack-4.0.0.gem (100%)
    Successfully installed actionpack-4.0.0
    Fetching: activemodel-4.0.0.gem (100%)
    Successfully installed activemodel-4.0.0
    Fetching: arel-4.0.0.gem (100%)
    Successfully installed arel-4.0.0
    Fetching: activerecord-deprecated_finders-1.0.3.gem (100%)
    Successfully installed activerecord-deprecated_finders-1.0.3
    Fetching: activerecord-4.0.0.gem (100%)
    Successfully installed activerecord-4.0.0
    Fetching: mime-types-1.23.gem (100%)
    Successfully installed mime-types-1.23
    Fetching: polyglot-0.3.3.gem (100%)
    Successfully installed polyglot-0.3.3
    Fetching: treetop-1.4.14.gem (100%)
    Successfully installed treetop-1.4.14
    Fetching: mail-2.5.4.gem (100%)
    Successfully installed mail-2.5.4
    Fetching: actionmailer-4.0.0.gem (100%)
    Successfully installed actionmailer-4.0.0
    Fetching: thor-0.18.1.gem (100%)
    Successfully installed thor-0.18.1
    Fetching: railties-4.0.0.gem (100%)
    Successfully installed railties-4.0.0
    Fetching: hike-1.2.3.gem (100%)
    Successfully installed hike-1.2.3
    Fetching: tilt-1.4.1.gem (100%)
    Successfully installed tilt-1.4.1
    Fetching: sprockets-2.10.0.gem (100%)
    Successfully installed sprockets-2.10.0
    Fetching: sprockets-rails-2.0.0.gem (100%)
    Successfully installed sprockets-rails-2.0.0
    Fetching: rails-4.0.0.gem (100%)
    Successfully installed rails-4.0.0
    Parsing documentation for i18n-0.6.4
    Installing ri documentation for i18n-0.6.4
    Parsing documentation for multi_json-1.7.8
    Installing ri documentation for multi_json-1.7.8
    Parsing documentation for tzinfo-0.3.37
    Installing ri documentation for tzinfo-0.3.37
    Parsing documentation for minitest-4.7.5
    Installing ri documentation for minitest-4.7.5
    Parsing documentation for atomic-1.1.12
    unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/atomic_reference.bundle, skipping
    Installing ri documentation for atomic-1.1.12
    Parsing documentation for thread_safe-0.1.2
    Installing ri documentation for thread_safe-0.1.2
    Parsing documentation for activesupport-4.0.0
    unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/active_support/values/unicode_tables.dat, skipping
    Installing ri documentation for activesupport-4.0.0
    Parsing documentation for builder-3.1.4
    /Users/aka/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding : ignored
    /Users/aka/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/rdoc/parser.rb:87: warning: Unsupported encoding  ignored
    Installing ri documentation for builder-3.1.4
    Parsing documentation for rack-1.5.2
    Installing ri documentation for rack-1.5.2
    Parsing documentation for rack-test-0.6.2
    Installing ri documentation for rack-test-0.6.2
    Parsing documentation for erubis-2.7.0
    Installing ri documentation for erubis-2.7.0
    Parsing documentation for actionpack-4.0.0
    Installing ri documentation for actionpack-4.0.0
    Parsing documentation for activemodel-4.0.0
    Installing ri documentation for activemodel-4.0.0
    Parsing documentation for arel-4.0.0
    Installing ri documentation for arel-4.0.0
    Parsing documentation for activerecord-deprecated_finders-1.0.3
    Installing ri documentation for activerecord-deprecated_finders-1.0.3
    Parsing documentation for activerecord-4.0.0
    Installing ri documentation for activerecord-4.0.0
    Parsing documentation for mime-types-1.23
    Installing ri documentation for mime-types-1.23
    Parsing documentation for polyglot-0.3.3
    Installing ri documentation for polyglot-0.3.3
    Parsing documentation for treetop-1.4.14
    Installing ri documentation for treetop-1.4.14
    Parsing documentation for mail-2.5.4
    unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/mail/values/unicode_tables.dat, skipping
    Installing ri documentation for mail-2.5.4
    Parsing documentation for actionmailer-4.0.0
    Installing ri documentation for actionmailer-4.0.0
    Parsing documentation for thor-0.18.1
    Installing ri documentation for thor-0.18.1
    Parsing documentation for railties-4.0.0
    Installing ri documentation for railties-4.0.0
    Parsing documentation for hike-1.2.3
    Installing ri documentation for hike-1.2.3
    Parsing documentation for tilt-1.4.1
    Installing ri documentation for tilt-1.4.1
    Parsing documentation for sprockets-2.10.0
    Installing ri documentation for sprockets-2.10.0
    Parsing documentation for sprockets-rails-2.0.0
    Installing ri documentation for sprockets-rails-2.0.0
    Parsing documentation for rails-4.0.0
    unable to convert "\x89" from ASCII-8BIT to UTF-8 for guides/assets/images/belongs_to.png, skipping
    [snip]
    unable to convert "\xFF" from ASCII-8BIT to UTF-8 for guides/assets/images/vijaydev.jpg, skipping
    Installing ri documentation for rails-4.0.0
    28 gems installed
    
      * To start using RVM you need to run `source /Users/aka/.rvm/scripts/rvm`
        in all your open shell windows, in rare cases you need to reopen all shell windows.
    
      * To start using rails you need to run `rails new `.
    $ 
    
    Make sure the latest versions of RVM, Ruby and Rails were installed.
    $ type rvm | head -1
    rvm is a function
    $ rvm -v
    
    rvm 1.21.18 (stable) by Wayne E. Seguin , Michal Papis  [https://rvm.io/]
    
    $ ruby -v
    ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
    $ rails -v
    Rails 4.0.0
    $ brew doctor
    Your system is ready to brew.
    $ 
    

Good! But this is a long way, isn't this?

0 件のコメント: