Ticket #4227 (closed defect: fixed)

Opened 1 year ago

Last modified 8 months ago

Cannot detect GIT version: All git commands result in git usage output which is unparsable.

Reported by: lhunath Assigned to: hvr
Priority: normal Component: GitPlugin
Severity: normal Keywords:
Cc: douglas@theros.info Trac Release: 0.11

Description

The cause of this issue is hidden until you disable the catching of it which masks it into the error message you see in the summary.

After disabling this try-catch block, you see the real cause:

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/trac/web/main.py", line 432, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.6/site-packages/trac/web/main.py", line 174, in dispatch
    chosen_handler)
  File "/usr/lib/python2.6/site-packages/trac/web/main.py", line 295, in _pre_process_request
    chosen_handler = filter_.pre_process_request(req, chosen_handler)
  File "/usr/lib/python2.6/site-packages/trac/versioncontrol/api.py", line 86, in pre_process_request
    self.get_repository(req.authname).sync()
  File "/usr/lib/python2.6/site-packages/trac/versioncontrol/api.py", line 132, in get_repository
    for connector in self.connectors
  File "/usr/lib/python2.6/site-packages/trac/core.py", line 67, in extensions
    return filter(None, [component.compmgr[cls] for cls in extensions])
  File "/usr/lib/python2.6/site-packages/trac/core.py", line 204, in __getitem__
    component = cls(self)
  File "/usr/lib/python2.6/site-packages/trac/core.py", line 108, in maybe_init
    init(self)
  File "build/bdist.linux-i686/egg/tracext/git/git_fs.py", line 66, in __init__
    self._version = PyGIT.Storage.git_version(git_bin=self._git_bin)
  File "build/bdist.linux-i686/egg/tracext/git/PyGIT.py", line 145, in git_version
    [v] = output.readlines()

It appears git was outputting:

usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]

The most commonly used git commands are:
   add        Add file contents to the index
...

Which is, for obvious reasons, not parsable into a version string.

The attached patch fixed the issue. Key is shell=False in the Popen call.

Without this patch, GitPlugin is completely useless, obviously.

I am unsure which environmental conditions triggered this bug; things used to run fine here until I did a system upgrade.

Attachments

no_shell_exec.patch (1.1 kB) - added by lhunath on 12/08/08 22:00:10.
Patch which fixes the issue.
no_shell_exec_cleaned.patch (0.8 kB) - added by lhunath on 12/08/08 22:08:29.
Cleaned up & working version of above patch - above patch might be bugged (see my comments on #3654)

Change History

12/08/08 22:00:10 changed by lhunath

  • attachment no_shell_exec.patch added.

Patch which fixes the issue.

12/08/08 22:08:29 changed by lhunath

  • attachment no_shell_exec_cleaned.patch added.

Cleaned up & working version of above patch - above patch might be bugged (see my comments on #3654)

01/10/09 15:27:53 changed by guardian

thank you for the patch apparently solved the "Could not retrieve GIT version" error message I got when installing on archlinux, Python 2.6

02/12/09 21:58:12 changed by George

Sadly this patch makes no difference here / Python 2.6 also

Trac[git_fs] ERROR: GitError?: Could not retrieve GIT version

:(

(follow-up: ↓ 4 ) 02/19/09 22:05:16 changed by Frank

I am having the exact same problem here. Patch doesn't work

I'm on Ubuntu 8.10

(in reply to: ↑ 3 ) 02/19/09 23:12:09 changed by anonymous

Replying to Frank:

I am having the exact same problem here. Patch doesn't work I'm on Ubuntu 8.10

Forget it. I just updated my version of GIT and it start working.

02/20/09 15:21:58 changed by anonymous

I love you. With this patch, it finally started working for me. Thank you :)

02/23/09 03:11:10 changed by thatch

Can anyone who hit this issue report on your OS and version of git?

02/23/09 11:47:26 changed by anonymous

The attached patch fixes the problem for me on:

openSUSE 11.1 git version 1.6.0.2 python 2.6

02/26/09 03:38:29 changed by douglas@theros.info

  • cc set to douglas@theros.info.
  • priority changed from high to highest.

python 2.5.2 git 1.5.6.3

I've tried the two patches above, still broken. I've raised the priority cause the plugin in its state is unusable

02/26/09 04:03:10 changed by douglas@theros.info

  • priority changed from highest to high.

I've found the culprit

you need to specify the full path to git exec when not in shell mode. With the second path and a full /usr/bin/git it started to work.

03/20/09 16:13:42 changed by hvr

  • status changed from new to closed.
  • resolution set to fixed.

should be fixed now in 0.11 branch; please reopen ticket if this is not the case

03/20/09 21:13:32 changed by brentl

  • priority changed from high to normal.
  • status changed from closed to reopened.
  • resolution deleted.
  • severity changed from blocker to normal.
        p = Popen(self.__build_git_cmd(git_cmd, *cmd_args),
                  stdin=None, stdout=PIPE, stderr=PIPE, close_fds=True)

This code fails on the Windows platform:

ValueError: close_fds is not supported on Windows platforms

The code without close_fds appears to work:

        p = Popen(self.__build_git_cmd(git_cmd, *cmd_args),
                  stdin=None, stdout=PIPE, stderr=PIPE)

but I'm not sure whether this would introduce an error under Unix, as the default is close_fds=False.

I've reopened the ticket, but, as I have this work-around, with a lower urgency.

03/20/09 21:26:09 changed by thatch

On Windows you can either leave out close_fds or set it to False. In the functional tests we have to deal with that... see trac/tests/functional/compat.py and then the usage in trac/tests/functional/tester.py. I don't think close_fds should be considered in the public api there, but something similar solves your problem as well.

03/24/09 07:29:37 changed by hvr

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [5396]) GitPlugin: omit close_fds=True on win32 platform (fixes #4227)

07/26/09 20:33:25 changed by czerwonka@arcticpenguin.ca

  • status changed from closed to reopened.
  • resolution deleted.

It appears that this issue has not gone away. I'm running Git 1.6.3.3 on suse 11.1 and I'm getting the same old 'Trac[git_fs] ERROR: GitError?: Could not retrieve GIT version' issue.

07/27/09 15:54:56 changed by czerwonka@arcticpenguin.ca

BTW, I'm using Trac 11.5.

07/27/09 16:03:36 changed by czerwonka@arcticpenguin.ca

I wrote the following snippet:

import PyGIT print(PyGIT.Storage.git_version())

which returned the following:

{'v_tuple': (1, 6, 3, 3), 'v_min_tuple': (1, 5, 6), 'v_compatible': True, 'v_min_str': '1.5.6', 'v_str': '1.6.3.3'}

This looks correct. I'm not sure why its giving me the exception. Any help with this would be greatly appreciated.

07/27/09 21:50:53 changed by thatch

  • status changed from reopened to closed.
  • resolution set to fixed.

Make sure you're using the latest version of the git plugin for trac as well, that's where the fix went in and the one version you didn't list. If you're using >= r5396 of the git plugin, please open a new ticket because it's likely a different issue.

07/28/09 01:14:10 changed by czerwonka@arcticpenguin.ca

I opened Ticket #5571.


Add/Change #4227 (Cannot detect GIT version: All git commands result in git usage output which is unparsable.)




Change Properties
Action