在bash脚本中安装和运行gem

时间:2013-05-28 15:26:50

标签: bash gem

我正在mac OSX中编写一个bash脚本。现在我想成立图书管理员 - 厨师,

echo "installing the librarian-chef gem"
gem install librarian-chef

echo "librarian-chef installing cookbooks from the recipies"
librarian-chef install

然后运行它。以便bash脚本的其余部分可以完成,但我继续得到这个line 31: librarian-chef: command not found

所以我认为gem安装得很好,但路径没有刷新,因此无法使用?所以我试过

echo "librarian-chef installing cookbooks from the recipies"
source ~/.bash_profile
librarian-chef install

这样它会刷新它但不起作用?

./vagrant_prepare.sh: line 30: ~/.bash_profile: No such file or directory

如何安装它,然后使用任何人看到这个?

我确实有bash个人资料btw

 ls -a
.           .bash_history       .dropbox        .rbenv      .viminfo        Dumps           Pictures        temp
..          .bash_profile       .gem            .redis          Desktop         Library         Public          test.sh
.CFUserTextEncoding .bundler        .gitconfig      .ruby-version       Documents       Movies          VirtualBox VMs
.DS_Store       .cache          .local          .ssh            Downloads       Music           Work
.Trash          .config         .pow            .vagrant.d      Dropbox         Nexus           chronosphere.sh

1 个答案:

答案 0 :(得分:1)

~/.bash_profile

中添加此内容
eval "$(rbenv init -)"

重新打开终端并再次运行脚本。

#!/bin/bash
echo "installing the librarian-chef gem"
gem install librarian-chef

echo "librarian-chef installing cookbooks from the recipies"
librarian-chef install