问题描述
为什么使用sudo时找不到命令bundle":
Why is command "bundle" not found when using 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 时确实存在:
but does exist when not using 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.
The reason I ask is I am following https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos, and it states to use sudo.
我已尝试添加 ,但得到此帐户当前不可用.".
I've tried adding a -i
flag as described by Using $ sudo bundle exec ... raises 'bundle: command not found' error, but get "This account is currently not available.".
推荐答案
检查 PATH
是否在有和没有 sudo
的情况下具有相同的值.显然它找不到 bundle
只是因为它没有在 PATH
Check if the PATH
has the same values both with and without sudo
. Apparently it cannot find bundle
just because it is not listed in PATH
您可以比较以下两行的输出
You can compare the outputs of following two lines
$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh
理想情况下,sudo
应该保持 PATH
不变.但这可能是您的托管分布的一个附带问题.
Ideally sudo
is supposed to leave PATH
untouched. But this might be a side issue of your hosting distribution.
由原始海报编辑.输出是:
Edit by original poster. Output is:
[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]#
这篇关于为什么找不到 sudo: bundle 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!