Question

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

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

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.".

Was it helpful?

Solution

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

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

OTHER TIPS

The user was created without a bash login shell. Change this in centos using system-config-users. Then su git into /home/git and move to gitlab directory. Execute the bundle commands without the sudo tag. The next error you will encounter is the missing database.yml in the config dir. fix this with the correct password (i.e. copy the mysql or postgres sample and edit).

I had this issue I thought that my gitlab installed from source and I got same error. but after try Omnibus method for backup my issue solved with this command:

sudo 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top