2

I am trying to install GitLab on a Debian Wheezy and experiencing an issue I don't understand.

Following the install guide for version 5.0:

  • step 1: was run as explained
  • step 2: I used rvm (multi-user install) instead (ruby-1.9.3-p392)
  • steps 3 to 5: were run as explained (MySQL chosen)
  • step 6: everything works fine until the "Install Gems" section, where I get the following error:
/home/git/gitlab$ sudo -u git -H bundle install --deployment --without development test postgres
sudo: unable to execute /usr/local/bin/bundle: No such file or directory

I run this as my normal user (in the sudo and rvm groups), and the git user is not a sudoer.

I think that the line sudo gem install bundler, in step 2, does not grant the git user to execute bundle properly, but I don't know how to fix this.

I probably did something wrong but cannot figure out what it is, as I tried to respect the standard instructions as close as possible.

Any clue about this? Thanks, I am losing hope...

For information, I have written to the GitLab mailing-list about this problem but did not get any answer. Moreover, last time I asked something similar on ServerFault, I have been advised to post on StackOverflow instead... hence this question :)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
astorije
  • 2,666
  • 2
  • 27
  • 39
  • By the way, I did not manage to show the bash line as code, if anyone wants to edit my post... – astorije Apr 03 '13 at 17:31
  • Can user `git` execute `bundle`? Where is `bundle` installed? – VonC Apr 03 '13 at 18:18
  • When I do `$ which bundle`, I get `/usr/local/rvm/gems/ruby-1.9.3-p392/bin/bundle`. The `git` user has been created with the `--disabled-login` flag and thus I cannot login as `git` to run `bundle`. When I do `$ sudo -u git bundle`, I get `sudo: unable to execute /usr/local/bin/bundle: No such file or directory` but my normal user can execute `bundle` even without `sudo`ing it. Does this answer your question? :s Also, thanks for editing my post, didn't think of the `
    ` tag!
    – astorije Apr 03 '13 at 20:21
  • 1
    That must be because `/usr/local/rvm/gems/ruby-1.9.3-p392/bin`isn't in the path of git. You have various solutions for that: http://stackoverflow.com/a/257666/6309 or http://superuser.com/q/98686/141 – VonC Apr 03 '13 at 21:03
  • @VonC Thanks for your advice. Reading those 2 links, there are plenty of solutions indeed. Many of them suggest to edit the `sudo`ers file with several changes, and those changes are ultimately considered as security mistakes by other people. It seems that running `sudo -i -u git bundle` instead of `sudo -u git bundle` does the trick. Should I go for the `-i` solution or should I edit the `sudo`ers file instead, according to you? – astorije Apr 04 '13 at 11:59
  • 1
    If you can avoid editing the sudoers file, it is always better. See my answer below. – VonC Apr 04 '13 at 12:08

2 Answers2

1

When I do $ which bundle, I get /usr/local/rvm/gems/ruby-1.9.3-p392/bin/bundle.
The git user has been created with the --disabled-login flag and thus I cannot login as git to run bundle.
When I do $ sudo -u git bundle, I get

sudo: unable to execute /usr/local/bin/bundle: No such file or directory

That means git user has not /usr/local/rvm/gems/ruby-1.9.3-p392/bin in its PATH, and you cannot modify its .profile or .bashrc because of the --disabled-login flag.

It seems that running sudo -i -u git bundle instead of sudo -u git bundle does the trick

That is the safest route, and will execute the command as git, but will simulate first an initial login, using the PATH defined in .profile and .bashrc of user root.
See "How does sudo search the path for executable?" for more.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `/usr/local/rvm/gems/ruby-1.9.3-p392/bin` is not in any `.profile` or `.bashrc` file of `root` or `git` users, so I don't know where it is set... Also, using `-i`, the current directory is `/home/git` but I need to `cd gitlab` before running `bundle`. Is there a better/cleaner way than doing `sudo -i -u git sh -c 'cd gitlab && bundle'`? It seems hackish to me... – astorije Apr 04 '13 at 15:14
  • @JérémieAstori and a `cd gitlab`, followed by a `sudo -i -u git bundle install ...` doesn't work? – VonC Apr 04 '13 at 15:15
  • Nop... And if I run `cd gitlab` followed by `sudo -i -u git pwd`, it outputs `/home/git`. – astorije Apr 04 '13 at 15:18
  • @JérémieAstori then the `cd && bundle` option you mentioned is worth a shot. – VonC Apr 04 '13 at 15:20
  • I will try it. It's odd though, as even the [TroubleShooting Guide](https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide) refers a lot to `sudo -u git bundle`, would there be a better way to edit the `git` user's PATH so that I don't need this weird command eventually? – astorije Apr 04 '13 at 15:24
  • @JérémieAstori I agree, editing the path in the `git` account would be ideal. – VonC Apr 04 '13 at 16:53
  • Do you know how I could do that? I mean, instead of setting it hardcoded. There are several additions to both my normal and `root` users but nothing for the git user (at the beginning of the `$PATH` variable). Nothing particular in the `sudo`ers file neither... – astorije Apr 04 '13 at 17:35
  • @JérémieAstori I am still looking into that. http://askubuntu.com/questions/243346/how-to-run-a-command-as-a-user-whose-login-is-disabled can be a good read on sudo though. Modifyinh root PATH remains the straightforward way: http://askubuntu.com/q/262064 – VonC Apr 04 '13 at 18:55
  • 1
    I am experiencing so many troubles to install GitLab on this ARM board that I will postpone its installation for now. Anyway, the `sudo -i -u git 'cd [...] && bundle install [...]'` works for this particular problem, so I will keep this as a solution and will update this topic if I (or you, maybe!) find a better way to do that. Congrats, you've won your upvote/accepted mention, and thanks above all :-) – astorije Apr 09 '13 at 16:34
  • @JérémieAstori You are most welcome. Another similar case (http://stackoverflow.com/a/15761971/6309) would involve "unlocking" the git account. Not ideal either. – VonC Apr 09 '13 at 17:06
  • @JérémieAstori that, or the sudoers NOPASSWD: http://stackoverflow.com/a/15861652/6309 – VonC Apr 09 '13 at 18:42
0

On my local machine after upgrade from 6.4 to 7.7 I had such issue.

The compilation of ruby was made under root account.

So need permissions to read compiled ruby and installed bundle.

chmod ugo+rx /usr/local/bin/bundle
chmod -R ugo+rX /usr/local/lib/ruby/

In production mode You could be more strict.

Fedir RYKHTIK
  • 9,844
  • 6
  • 58
  • 68