[英]Why is sudo: bundle command not found?
Why is command "bundle" not found when using sudo:为什么在使用 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]#
but does exist when not using sudo:但在不使用 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]#
The reason I ask is I am following https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos , and it states to use sudo.我问的原因是我正在关注https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos ,并声明使用 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.".我已经尝试添加一个
-i
标志,如Using $ sudo bundle exec ... raises 'bundle: command not found' error ,但得到“此帐户当前不可用。”。
Check if the PATH
has the same values both with and without sudo
.检查
PATH
在使用和不使用sudo
是否具有相同的值。 Apparently it cannot find bundle
just because it is not listed in PATH
显然它找不到
bundle
只是因为它没有在PATH
列出
You can compare the outputs of following two lines您可以比较以下两行的输出
$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh
Ideally sudo
is supposed to leave PATH
untouched.理想情况下
sudo
应该保持PATH
不变。 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]#
The user was created without a bash login shell.该用户是在没有 bash 登录 shell 的情况下创建的。 Change this in centos using system-config-users.
使用 system-config-users 在 centos 中更改此设置。 Then su git into /home/git and move to gitlab directory.
然后 su git 进入 /home/git 并移动到 gitlab 目录。 Execute the bundle commands without the sudo tag.
执行不带 sudo 标签的 bundle 命令。 The next error you will encounter is the missing database.yml in the config dir.
您将遇到的下一个错误是配置目录中缺少 database.yml。 fix this with the correct password (ie copy the mysql or postgres sample and edit).
使用正确的密码修复此问题(即复制 mysql 或 postgres 示例并进行编辑)。
I had this issue I thought that my gitlab installed from source and I got same error.我遇到了这个问题,我认为我的 gitlab 是从源代码安装的,但出现了同样的错误。 but after try Omnibus method for backup my issue solved with this command:
但是在尝试使用 Omnibus 备份方法后,我的问题用这个命令解决了:
sudo gitlab-rake gitlab:backup:create
须藤 gitlab-rake gitlab:backup:create
Try :尝试 :
sudo -u git -H env PATH=$PATH && bundle exec rake gitlab:check RAILS_ENV=production
to use the same PATH
than current user.使用与当前用户相同的
PATH
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.