すがブロ

sugamasaoのhatenablogだよ

MacBookPro(Snow Leopard)に開発環境を構築するメモ

MacPorts をインストール

から Snow Leopard 用のバイナリを DL してインストール。そうすると、/opt/local/bin/port がインストールされる。
~/.zshrc にとりあえず PATH を追加する(.zshrc は以前使っていたものに書き換えるので、暫定的に書くだけ)。

export PATH=/opt/local/bin:$PATH

読み込み直す

source .zshrc

以降は sudo port 行った後の記録である。

port メモ

毎回手探り気分なのだけど、とりあえず以下だけでも覚えておけば良い。

search subversion

とかで、関連する port ファイル一覧が出てくる。

info subversion

で、 subversion パッケージの詳細が見れる。 variants が重要。

svn をインストール

[Users/sugamasao] > install subversion +bash_complete +mod_dav_svn

perl をインストール

[Users/sugamasao] > install perl5.12 +dtrace

dtrace が必要なのかはよくわからん。が、gitをインストールする祭に必要らしいので、先にインストールしておく事にする。

git をインストール

[Users/sugamasao] > install git-core +bash_completion +doc +gitweb +svn

とりあえずフルパワーの variants でインストール*1

python をインストール

とりあえず 2.x 系の最新にする。
python_select をインストールせよ、といわれたので、そちらを先にインストールする。

[Users/sugamasao] > install python_select
[Users/sugamasao] > install python27

readline のインストール

標準で入っている readline は日本語をうまく扱えないそうなので、ports 経由でインストールしておく。

[Users/sugamasao] > install readline

ruby をインストール

rvm をインストールするにも、gem でインストールするためには最初に Ruby が入っていないといけないので、一旦普通に Ruby を入れる。
一応、1.8系の最新版をインストール。終わったら gem のインストールもしておく。

[Users/sugamasao] > install ruby @1.8.7-p249
[Users/sugamasao] > rb-rubygems @1.3.5

screen のインストール

これ由来の対応。もしかしたら、OSも新しくなってるので対応されてるかもしれないが。。。

cd /tmp
mkdir ./hoge
cd hoge
svn co http://svn.macports.org/repository/macports/trunk/dports/sysutils/screen@45522 sysutils/screen
cd sysutils/screen
sudo port install

インストールされる。

rvm のインストール

これは MacPorts 経由ではない。
gem から rvm をインストールする。以下を参考にした。

sudo gem install rvm

そうすると、こんなことを言われる。

********************************************************************************

  In order to setup rvm for your user's environment you must now run rvm-install.
  rvm-install will be found in your current gems bin directory corresponding to where the gem was installed.

  rvm-install will install the scripts to your user account and append itself to your profiles in order to
  inject the proper rvm functions into your shell so that you can manage multiple rubies.

********************************************************************************

rvm-install せよ、ということなので実行する。

rvm-install

実行すると、もの凄い勢いでいろいろ言われる。

RVM:   shell scripts which allow management of multiple ruby interpreters and environments.
RTFM:  http://rvm.beginrescueend.com/
HELP:  http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

* Installing rvm to /Users/sugamasao/.rvm/
Notes for Darwin ( Mac OS X ) 

    *  For Snow Leopard be sure to have XCode Tools Version 3.2.1 (1613) or later (there were bugs with the dvd release version).
    *  You should download the latest XCode tools from developer.apple.com. This is necessary since the dvd install for Snow Leopard has bugs.
    *  If you intend on installing MacRuby you must install LLVM first.
    *  If you intend on installing JRuby you must install the JDK.
    *  If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).


sugamasao,

Thank you for using rvm. I hope that it makes your work easier and more enjoyable.
If you have any questions, issues and/or ideas for improvement please hop in #rvm on irc.freenode.net and let me know.
My irc nickname is 'wayneeseguin' and I hang out from ~09:00-17:00EST and again from ~21:00EST-~00:00EST.
If I do not respond right away, please hang around after asking your question, I will respond as soon as I am back.
Be sure to get head often as rvm development happens fast, you can do this by typing 'rvm update --head'.
  w⦿‿⦿t!
    ~ Wayne

You must now finish the install manually:
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
2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly).
   This means that if you see '[ -z  ] && return' then you must change this line to:
   if [[ ! -z  ]] ; then
     ... original content that was below the && return line ...
   fi # <= be sure to close the if.
   #EOF .bashrc
   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 items in the .bashrc, including the 'source' line above
3) Then CLOSE THIS SHELL and open a new one in order to use rvm.

Installation of RVM to /Users/sugamasao/.rvm/ is complete.

.zshrc に 1) のスクリプトを記載してシェルを再起動。

rvm list known

でインストールできる Ruby 一覧が見れる。
とりあえず、1.9.1-head と 1.9.2-head をインストールしておく。
以下のオプションは、 readline をports経由に切り替えるために設定しておく。

rvm install ruby-1.9.1-head -C "--enable-shared=true,--with-opt-dir=/opt/local"
rvm install ruby-1.9.2-head -C "--enable-shared=true,--with-opt-dir=/opt/local"

とりあえず

こんなモンで良いかな。
あとは必要に応じてインストールしていけば良いか。

*1:+svn と +bash_completion は必須ですね