10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

installしたはずなのにコマンドが見つからない時の対処法φ(・・*)

Last updated at Posted at 2014-08-20

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

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?