heroku toolbeltをCentOS6(さくらVPS上)で使えるようにするまで。

先に結論として、


公式サイトのheroku toolbeltのインストール手順から、

$ wget --no-check-certificate https://toolbelt.heroku.com/install.sh
$ sh install.sh
$ echo 'PATH="/usr/local/heroku/bin:$PATH"' >> ~/.zshrc.mine
$ source ~/.zshrc

で、インストールした後に、

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc.mine
$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc.mine
$ source ~/.zshrc

rbenv ruby-buildsいれて、

$ rbenv install 2.1.1
$ rbenv global 2.1.1
$ gem install netrc && gem install heroku-api && gem install rest-client
$ heroku login

最新(っぽい?)Rubyとnetrc、heroku-api入れたら動いた。


以下、「こんなことやっても動かなかった」NG集です。


PATH="/usr/local/heroku/bin:$PATH をやらない場合

$ heroku version
zsh: command not found: heroku

Ruby入れずにheroku toolbeltのみインスコした場合

$ heroku version
/usr/bin/env: ruby: そのようなファイルやディレクトリはありません

yum使ってRubyインスコした場合(ruby version < 1.9.2)

$ sudo yum install -y ruby rubygems
$ sudo yum info ruby
Installed Packages
Name        : ruby
Arch        : x86_64
Version     : 1.8.7.352
Release     : 13.el6
Size        : 1.8 M
Repo        : installed
From repo   : updates
Summary     : An interpreter of object-oriented scripting language
URL         : http://www.ruby-lang.org/
License     : Ruby or GPLv2
Description : Ruby is the interpreted scripting language for quick and easy
            : object-oriented programming.  It has many features to process text
            : files and to do system management tasks (as in Perl).  It is simple,
            : straight-forward, and extensible.

$ sudo yum info rubygems
Installed Packages
Name        : rubygems
Arch        : noarch
Version     : 1.3.7
Release     : 5.el6
Size        : 713 k
Repo        : installed
From repo   : base
Summary     : The Ruby standard for packaging ruby libraries
URL         : http://rubyforge.org/projects/rubygems/
License     : MIT
Description : RubyGems is the Ruby standard for publishing and managing third party
            : libraries.


以上のRuby、gemのバージョンでやった結果が以下

$ sudo gem install netrc && sudo gem install heroku-api
$ heroku version
/usr/local/heroku/lib/heroku/auth.rb:6:in `require': no such file to load -- netrc (LoadError)
        from /usr/local/heroku/lib/heroku/auth.rb:6
        from /usr/local/heroku/lib/heroku/client.rb:4:in `require'
        from /usr/local/heroku/lib/heroku/client.rb:4
        from /usr/local/heroku/lib/heroku.rb:1:in `require'
        from /usr/local/heroku/lib/heroku.rb:1
        from /usr/local/heroku/lib/heroku/cli.rb:4:in `require'
        from /usr/local/heroku/lib/heroku/cli.rb:4
        from /usr/local/heroku/bin/heroku:22:in `require'
        from /usr/local/heroku/bin/heroku:22


Rubyのバージョン低いと何やってもダメ。

sudo gem install herokuをやってみる

$ sudo gem install heroku
ERROR:  Error installing heroku:
        mime-types requires Ruby version >= 1.9.2.


ここまで来て、「あ、古いRubyじゃダメなんだ。」と
rbenvを入れることを決意