为什么没有findsudo:bundle命令?

为什么使用sudo时找不到命令“bundle”:

[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。

我已经尝试添加-i标志,如使用$ sudo bundle exec所描述的…引发'bundle:command not found'错误 ,但得到“此帐户当前不可用”。

检查PATH是否具有与使用sudo相同的值。 显然它不能仅仅因为它没有在PATH列出而找到bundle

你比较下面两行的输出

 $ 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]# 

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

试试:

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

使用与当前用户相同的PATH