Mac OS X 開発環境構築手順:Homebrewインストール

Homebrewインストールに必要な環境は以下の通り。

An Intel CPU 2
OS X 10.5 or higher
Command Line Tools for Xcode or Xcode 3with X11 4
Java Developer Update 5

そして、Xcodeについてはこの作業を行う前にインストールを行う必要がありました。『Command Line Tools for Xcode』で事足りるというアドバイスを頂きましたので、そちらを導入(手順は以下)。


Xcode導入後の手順を以下にメモ。

  • 『/usr/local』フォルダを作成。(※存在しない場合) sudo経由で作成するのでパスワードを入力。
$ sudo mkdir /usr/local
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:************************ 【ログインパスワードを入力】
  • 所定のコマンドを入力(下記コード1行目:上記サイトからコピペして実行が吉)。
$ /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...
==> The following directories will be made group writable:
/usr/local/.
==> The following directories will have their group set to admin:
/usr/local/.

Press enter to continue
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/.
Password:************************ 【ログインパスワードを入力】
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/.
==> Downloading and Installing Homebrew...
==> Installation successful!
You should run `brew doctor' *before* you install anything.
Now type: brew help
$ 
  • 環境変数の追加を行う。ログインユーザの .bash_profile に以下の内容を追記。『source .bash_profile』で反映。
...
...

PATH=/usr/local/bin:$PATH
export PATH
  • インストール確認として、バージョンが出るか試してみる。
$ brew -v
  • また、インストールしたいキーワードでも検索してみる。
$ brew search groovy
groovy       groovyserv
  • (追記)brew versions』等を使うために、上記処理終了後『brew update』コマンドを実行。
$ brew update
Initialized empty Git repository in /usr/local/.git/
remote: Counting objects: 74137, done.
remote: Compressing objects: 100% (36578/36578), done.
remote: Total 74137 (delta 50150), reused 58276 (delta 36749)
Receiving objects: 100% (74137/74137), 10.58 MiB | 317 KiB/s, done.
Resolving deltas: 100% (50150/50150), done.
From https://github.com/mxcl/homebrew
 * [new branch]      gh-pages   -> origin/gh-pages
 * [new branch]      go         -> origin/go
 * [new branch]      master     -> origin/master
HEAD is now at 54d2abc jailkit 2.15
Already up-to-date.
$ 

参考サイト:

Mac OS X 開発環境構築手順:Gitインストール

MacにおけるGit環境のインストールにはHomebrewを用いましたが、あっけない程ちょ〜〜簡単でした。エントリにするまでも無いかもですが(笑)、一応記録として。

まずは以下の手順を元に、Homebrewをインストール。手間としてはJDKXcodeのインストールが事前に必要です。

あとは、以下のコマンド(brew install git)を実行するだけ。何とも簡単です。

$ brew search git
bagit		  git-diffall	    git-ftp	      git-multipush	git-ssh		  git-url-sub	    gitslave	      magit		willgit
git		  git-extras	    git-gerrit	      git-now		git-subtree	  git-utils	    legit	      stgit
git-cola	  git-flow	    git-hg	      git-sh		git-svn-abandon	  giter8	    libgit2	      topgit
shinyaa31-no-MacBook-Air:~ shinyaa31$ brew install git
==> Downloading http://git-core.googlecode.com/files/git-1.7.9.5.tar.gz
######################################################################## 100.0%
==> make prefix=/usr/local/Cellar/git/1.7.9.5 CC=/usr/bin/clang CFLAGS=-Os -w -pipe -march=native -Qunused-arguments LDFLAGS= install
==> Downloading http://git-core.googlecode.com/files/git-manpages-1.7.9.5.tar.gz
######################################################################## 100.0%
==> Downloading http://git-core.googlecode.com/files/git-htmldocs-1.7.9.5.tar.gz
######################################################################## 100.0%
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

The 'contrib' directory has been installed to:
  /usr/local/share/git-core/contrib
Warning: Non-libraries were installed to "lib".
Installing non-libraries to "lib" is bad practice.
The offending files are:
/usr/local/Cellar/git/1.7.9.5/lib/Git.pm
==> Summary
/usr/local/Cellar/git/1.7.9.5: 1157 files, 23M, built in 41 seconds
$ 
  • Gitのインストール確認用にバージョンを確認。
$ git --version
git version 1.7.9.5

今日のつぶやき 2012/04/04

Mac OS X 開発環境構築手順:Groovy/Gradleインストール

開発言語であるGroovyとビルドツールであるGradle。まとめてインストール記録をメモ。

※当手順についてはHomebrewをベースにしているため、事前にHomebrewのインストールが必要です。詳細は以下を参照

Groovyのインストール

  • んで、手順。brewコマンドで一発です。
$ brew search groovy
groovy	    groovyserv
$ brew install groovy
==> Downloading http://dist.groovy.codehaus.org/distributions/groovy-binary-1.8.6.zip
######################################################################## 100.0%
==> Caveats
You should set the environment variable GROOVY_HOME to
  /usr/local/Cellar/groovy/1.8.6/libexec
Warning: Non-executables were installed to "bin".
Installing non-executables to "bin" is bad practice.
The offending files are:
/usr/local/Cellar/groovy/1.8.6/bin/startGroovy
==> Summary
/usr/local/Cellar/groovy/1.8.6: 39 files, 17M, built in 2.0 minutes
$ 
  • インストール後、バージョンを確認。
$ groovy -v
Groovy Version: 1.8.6 JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X
$ 
  • サンプル的にファイルを作成し、実行してみる。
$ vi test.groovy
----------------
println 'Hello, Groovy!!'
----------------
$ groovy test.groovy
Hello, Groovy!!

Gradleのインストール

  • こちらもbrewコマンドで一発。
$ brew search gradle
gradle
$ brew install gradle
==> Downloading http://services.gradle.org/distributions/gradle-1.0-milestone-9-bin.zip
######################################################################## 100.0%
/usr/local/Cellar/gradle/1.0-milestone-9: 80 files, 32M, built in 4.1 minutes
$ 
  • インストール後、バージョンを確認。
$ gradle -v

------------------------------------------------------------
Gradle 1.0-milestone-9
------------------------------------------------------------

Gradle build time: 2012?N3??13?? 16??10??09?b UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_29 (Apple Inc. 20.4-b02-402)
OS: Mac OS X 10.7.3 x86_64

$ 
$ vi .bash_profile
:
:
GRADLE_HOME=/usr/local/Cellar/gradle/1.0-milestone-9
export GRADLE_HOME

PATH=$PATH:$GRADLE_HOME/bin
export PATH

$ source vi .bash_profile
  • こちらもサンプルコードを作成し、実行してみる。
$ vi build.gradle
-----------------------------------------
task helloWorld << {
    println 'hello, gradle!!'
}
-----------------------------------------
$ gradle -q helloWorld
hello, gradle!!
$ 

参考サイト: