为什么没有找到sudo:bundle命令?

时间:2014-03-17 14:28:20

标签: ruby linux rubygems bundler sudo

为什么命令"捆绑"使用sudo时找不到:

[root@desktop gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
sudo: bundle: command not found
[root@desktop gitlab]#

但在不使用sudo时确实存在:

[root@desktop gitlab]# bundle exec rake gitlab:setup RAILS_ENV=production
 Warning
  You are running as user root, we hope you know what you are doing.
  Things may work/fail for the wrong reasons.
  For correct results you should run this as user git.

This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? no
Quitting...
[root@desktop gitlab]#

我问的原因是我关注https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos,并声明使用sudo。

我已尝试按Using $ sudo bundle exec ... raises 'bundle: command not found' error所述添加-i标记,但获取"此帐户目前无法使用。"。

4 个答案:

答案 0 :(得分:18)

检查PATH是否具有sudo的相同值。显然它找不到bundle只是因为它没有列在PATH

您可以比较以下两行的输出

$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh

理想情况下,sudo应该保持PATH不受影响。但这可能是您托管分发的一个侧面问题。

按原始海报编辑。输出是:

[root@desktop etc]# echo 'echo $PATH' | sh
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@desktop etc]# echo 'echo $PATH' | sudo sh
/sbin:/bin:/usr/sbin:/usr/bin:/user/local/bin
[root@desktop etc]#

答案 1 :(得分:1)

创建的用户没有bash登录shell。使用system-config-users在centos中更改此设置。然后su git进入/ home / git并移动到gitlab目录。执行不带sudo标记的bundle命令。您将遇到的下一个错误是config dir中缺少database.yml。使用正确的密码修复此问题(即复制mysql或postgres示例并编辑)。

答案 2 :(得分:1)

我遇到了这个问题,我认为我的gitlab是从源代码安装的,并且出现了相同的错误。但是尝试了Omnibus备份方法后,我的问题解决了 使用以下命令:

  

sudo gitlab-rake gitlab:backup:create

答案 3 :(得分:0)

尝试:

sudo -u git -H env PATH=$PATH && bundle exec rake gitlab:check RAILS_ENV=production

使用与当前用户相同的PATH