git hooks have an incorrect interpreter when installed under uwsgi

Issue #333 resolved
Thomas De Schampheleire created an issue

The shebang for git hooks is determined via: (kallithea/model/scm.py)

    tmpl_pre = "#!/usr/bin/env %s\n" % sys.executable or 'python2'

When Kallithea is run via uwsgi, 'sys.executable' is the uwsgi process, not the python interpreter. As a result, pushing to a git repo gives following error:

git push                                                                                                                                                                                                  
Password for 'http://user@localhost:5050': 
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 241 bytes | 241.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: unable to load configuration from hooks/pre-receive
To http://localhost:5050/gitrepo-new
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://user@localhost:5050/gitrepo-new'

There is a second issue reported on IRC by where the shebang uses '/usr/bin/python' when Kallithea is started using Apache+WSGI. It may or may not be the same issue).

Comments (4)

  1. Mads Kiilerich

    If modwsgi uses '/usr/bin/python' then that must be a problem of modwsgi ... or configurable?

    But I can see how uwsgi also kind of is right.

    Can we enumerate in which cases we want which? Can we imagine a heuristic that really cover all cases and not just the cases we happen to come up with? Perhaps use a more complex heuristic ... and make it configurable to override that? Perhaps only use sys.executable if the last slash is followed by python?

  2. Log in to comment