macのスリープ復帰時に音が聞こえなくなる症状を直すために、osの再インストールしたんだけど、rbenv,home brew,MacPortsの環境が完全にぶっ壊れたのでそのときのメモ。あとmysqlを使えなくなってて再インストールした。
(過去にrbenvをインストールして使っていたんだけど、mac os xを再インストールしたら、rbenvを使えなくなった。)

refs:mavericksをアンインストールしたら、rbenvが消えた件

$ rbenv
-bash: rbenv: command not found

で、消えたのかと思い、brewで再度インストールしたら既にインストールされているというメッセージが・・・
$ brew install rbenv ruby-build
Warning: rbenv-0.4.0 already installed
Error: ruby-build-20140110.1 already installed
To install this version, first `brew unlink ruby-build'
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.

たしかに残ってはいるようだ・・・
$ brew list rbenv
/usr/local/Cellar/rbenv/0.4.0/bin/ruby-local-exec
/usr/local/Cellar/rbenv/0.4.0/bin/rbenv
/usr/local/Cellar/rbenv/0.4.0/completions/ (2 files)
/usr/local/Cellar/rbenv/0.4.0/libexec/ (25 files)

brew doctorは・・・
$ brew doctor
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

    /opt/local/bin/apr-1-config
    /opt/local/bin/apu-1-config
    /opt/local/bin/freetype-config
    /opt/local/bin/gpg-error-config
    /opt/local/bin/krb5-config
    /opt/local/bin/libgcrypt-config
    /opt/local/bin/libpng-config
    /opt/local/bin/libpng16-config
    /opt/local/bin/Magick++-config
    /opt/local/bin/Magick-config
    /opt/local/bin/MagickCore-config
    /opt/local/bin/MagickWand-config
    /opt/local/bin/ncurses5-config
    /opt/local/bin/ncursesw5-config
    /opt/local/bin/pcap-config
    /opt/local/bin/pcre-config
    /opt/local/bin/pkg-config
    /opt/local/bin/python2.7-config
    /opt/local/bin/Wand-config
    /opt/local/bin/xml2-config
    /opt/local/bin/xslt-config

Warning: You have MacPorts or Fink installed:
  /opt/local/bin/port

This can cause trouble. You don't have to uninstall them, but you may want to
temporarily move them out of the way, e.g.

  sudo mv /opt/local ~/macports

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:

    mysql

Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:

    brew install freetype

Run `brew missing` for more details.

Warning: You have a non-Homebrew 'pkg-config' in your PATH:
  /opt/local/bin/pkg-config

`./configure` may have problems finding brew-installed packages using
this other pkg-config.


メッセージ通りにgreetypeをインストール
$ brew install freetype

これでもまだ、brew doctroを実行しても色々とメッセージが出る

brew listでインストール済みリストを確認
$ brew list
apple-gcc42        gnupg            libpng            mysql-connector-c    rbenv
autoconf        jbig2dec        libtiff            nkf            rbenv-gem-rehash
cmake            jpeg            little-cms2        node            rbenv-gemset
freetype        jq            memcached        openssl            readline
ghostscript        libevent        mysql            pkg-config        ruby-build
$ brew list
apple-gcc42        gnupg            libpng            mysql-connector-c    rbenv
autoconf        jbig2dec        libtiff            nkf            rbenv-gem-rehash
cmake            jpeg            little-cms2        node            rbenv-gemset
freetype        jq            memcached        openssl            readline
ghostscript        libevent        mysql            pkg-config        ruby-build

rbenvが半端な状態で残っているので、アンインストールしてから再度インストール
$ brew install rbenv
Warning: rbenv-0.4.0 already installed
$ brew uninstall rbenv
Uninstalling /usr/local/Cellar/rbenv/0.4.0...

$ brew install rbenv
==> Downloading https://github.com/sstephenson/rbenv/archive/v0.4.0.tar.gz
######################################################################## 100.0%
==> Caveats
To use Homebrew's directories rather than ~/.rbenv add to your profile:
  export RBENV_ROOT=/usr/local/var/rbenv

To enable shims and autocompletion add to your profile:
  if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
==> Summary
🍺  /usr/local/Cellar/rbenv/0.4.0: 31 files, 152K, built in 3 seconds
$ which rbenv
/usr/local/bin/rbenv
$ rbenv versions
  system
* 2.0.0-p353 (set by /Users/shin/.rbenv/version)

一応直ったか・・・

まだ、rbenv installがない
~ $ rbenv install --list
rbenv: no such command `install'

どうやら、rbenv installを実行するには、rbenv-buildが必要らしい。rbenv listで見るとあるんだけどね・・・これもuninstallしてからinsltallする。

で、rbenvを使っている適当なrubyのwebアプリを実行しようとしたら、mysql2/mysq2がloadできないとかいうエラーが出た。で、gemのmysql,mysql2をアンインストールしてインストールし直そうとしたら、これもできない。

つか、brewのインストール済みのツールが全て使えなくなっていた・・・
~ $  brew list
apple-gcc42        jpeg            mysql            rbenv-gem-rehash
autoconf        jq            mysql-connector-c    rbenv-gemset
cmake            libevent        nkf            readline
freetype        libpng            node            ruby-build
ghostscript        libtiff            openssl
gnupg            little-cms2        pkg-config
jbig2dec        memcached        rbenv
~ $

で、こいつらを1個ずつuninstallしてinstallし直した。当然だけど時間がかかった。。。
その後に、gemでmysql,mysql2をインストールしてみたらできた。rubyのアプリの問題も解決。
apple-gcc42あたりが怪しかった。

あと、macportsも入れ直した。