编程语言
首页 > 编程语言> > ruby – 为什么没有找到sudo:bundle命令?

ruby – 为什么没有找到sudo: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.

我已尝试按照Using $sudo bundle exec … raises ‘bundle: command not found’ error所述添加-i标志,但获取“此帐户目前无法使用.”.

解决方法:

检查PATH是否具有相同的值,无论是否有sudo.显然它无法找到捆绑仅仅因为它没有在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]#

标签:ruby,linux,rubygems,bundler,sudo
来源: https://codeday.me/bug/20190930/1836511.html