Push to GitLab: ! [remote rejected] master -> master (pre-receive hook declined)


Attempted to push local repository to GitLab and got the following error:

Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 220 bytes | 73.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_net.rb:153:in `parse_who': undefined method `start_with?' for nil:NilClass (NoMethodError)
remote:         from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_net.rb:31:in `check_access'
remote:         from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_access.rb:27:in `block in exec'
remote:         from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_metrics.rb:50:in `measure'
remote:         from /opt/gitlab/embedded/service/gitlab-shell/lib/gitlab_access.rb:26:in `exec'
remote:         from hooks/pre-receive:30:in `<main>'
To <my_gitlab_server>:<path_to_repo>
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@<my_gitlab_server>:<path_to_repo>'

Using GitLab Community Edition version 11.4.0 installed on a Linux server and Git Bash version 2.19.1 64-bit for Windows.

I created a project in the GitLab UI and attempted a push from the local repository to this project, for which I have Maintainer status.


The error message looks like it has nothing to do with gitlab, but it is a pure git thing.

The pre-receive hook on the project found some error(s) and declined your push, if I remember correctly the lines with “remote:” are the output from the hooks (last time I experienced that, I had hit a bug in the hook (as well as in what I was trying to push) so I got absolutely nothing (of value)).

I think the most interesting part of the error is

in parse_who': undefined methodstart_with?’ for nil:NilClass (NoMethodError)


Here are some more details:

Initially, I created an empty repository in GitLab and cloned this to a local repository. Then, I made some changes in the local repository and attempted to push the changes to GitLab, which is when I got the error message above.

The local pre-receive hook is not in use (.sample), but the one being called is the default pre-receive hook placed by GitLab.

If you have more experience on how to read / interpret the error message, that would be helpful.