chefとknifeをつかえるようにしようとしたらつまづいたのでメモ。
先輩に教えて頂きました。
まずは、chefをgemでinstall
% gem i chef --no-ri --no-rdoc
よしこれで、と思いきや、、
% knife configure
zsh: command not found: knife
% gem list | grep chef
chef (11.14.6)
chef-zero (2.2)
あれれ、、
先輩がおっしゃるには、Rubyのバージョンとかによって、インストールされる場所が異なることが原因とのこと。その場合は、下記で探して環境変数に入れて、そのコマンドを登録しておくと良いとのこと。
% locate knife
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
教えてくれたコマンドをそのまま打つ
% sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
% locate knife
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
また怒られたので、
% sudo /usr/libexec/locate.updatedb
これで、locate
が使えるようになる。
% locate knife | grep bin
/Users/username/.rbenv/versions/2.1.2/bin/knife
でパスを探して、binまでを下記のようにセット
% setenv PATH /Users/username/.rbenv/versions/2.1.2/bin:$PATH
これをコピって、zshやbashのprofileに登録する
% vi .zsh_profile
これで、無事、knife
コマンドがつかえるようにヾ(´∀`o)+。
追記
rbenvで管理してる場合、rbenv rehash
を忘れていることが原因だったり、、、orz
rbenv rehashは何をやっているのか? - DQNEO起業日記
http://dqn.sakusakutto.jp/2014/02/rbenv_rehash_what_it_does.html
(環境構築ってやる回数少ないから、忘れる。。。)
そして、↓これ便利そう
Ruby - rbenv を使っているなら rbenv-gem-rehash を使おう - Qiita
http://qiita.com/riocampos/items/f0fe7217972b312c4f3a