Modify

Opened 15 years ago

Closed 9 years ago

#4227 closed defect (wontfix)

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

Reported by: lhunath Owned by: Herbert Valerio Riedel
Priority: normal Component: GitPlugin
Severity: normal Keywords:
Cc: douglas@… 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 (3)

no_shell_exec.patch (1.1 KB) - added by lhunath 15 years ago.
Patch which fixes the issue.
no_shell_exec_cleaned.patch (811 bytes) - added by lhunath 15 years ago.
Cleaned up & working version of above patch - above patch might be bugged (see my comments on #3654)
PyGIT.py.patch (1.2 KB) - added by cornbob@… 13 years ago.
tracext/git/PyGIT.py.patch

Download all attachments as: .zip

Change History (25)

Changed 15 years ago by lhunath

Attachment: no_shell_exec.patch added

Patch which fixes the issue.

Changed 15 years ago 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)

comment:1 Changed 15 years ago 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

comment:2 Changed 15 years ago by George

Sadly this patch makes no difference here / Python 2.6 also

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

:(

comment:3 Changed 15 years ago by Frank

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

I'm on Ubuntu 8.10

comment:4 in reply to:  3 Changed 15 years ago 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.

comment:5 Changed 15 years ago by anonymous

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

comment:6 Changed 15 years ago by Tim Hatch

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

comment:7 Changed 15 years ago by anonymous

The attached patch fixes the problem for me on:

openSUSE 11.1 git version 1.6.0.2 python 2.6

comment:8 Changed 15 years ago by douglas@…

Cc: douglas@… added; anonymous removed
Priority: highhighest

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

comment:9 Changed 15 years ago by douglas@…

Priority: highesthigh

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.

comment:10 Changed 15 years ago by Herbert Valerio Riedel

Resolution: fixed
Status: newclosed

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

comment:11 Changed 15 years ago by Brent Longborough

Priority: highnormal
Resolution: fixed
Severity: blockernormal
Status: closedreopened
        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.

comment:12 Changed 15 years ago by Tim Hatch

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.

comment:13 Changed 15 years ago by Herbert Valerio Riedel

Resolution: fixed
Status: reopenedclosed

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

comment:14 Changed 15 years ago by czerwonka@…

Resolution: fixed
Status: closedreopened

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.

comment:15 Changed 15 years ago by czerwonka@…

BTW, I'm using Trac 11.5.

comment:16 Changed 15 years ago by czerwonka@…

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.

comment:17 Changed 15 years ago by Tim Hatch

Resolution: fixed
Status: reopenedclosed

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.

comment:18 Changed 15 years ago by czerwonka@…

I opened Ticket #5571.

comment:19 Changed 13 years ago by cornbob@…

Resolution: fixed
Status: closedreopened

Hello,

I tried last week the latest version of trac (0.12) with gitplugin. That failed of cause of this bug. I tried today the version 0.11 of trac with the gitplugin for 0.11 the same error.

my git version is git version 1.6.4.2

comment:20 in reply to:  19 ; Changed 13 years ago by anonymous

Replying to cornbob@web.de:

Hello,

I tried last week the latest version of trac (0.12) with gitplugin. That failed of cause of this bug. I tried today the version 0.11 of trac with the gitplugin for 0.11 the same error.

my git version is git version 1.6.4.2

I also checked it against another machine with debian running git version 1.7.2.3

comment:21 in reply to:  20 Changed 13 years ago by anonymous

Replying to anonymous:

Replying to cornbob@web.de:

Hello,

I tried last week the latest version of trac (0.12) with gitplugin. That failed of cause of this bug. I tried today the version 0.11 of trac with the gitplugin for 0.11 the same error.

my git version is git version 1.6.4.2

I also checked it against another machine with debian running git version 1.7.2.3 and it worked perfectly in less than 12min :D

. The following "patch" does work for me... but this is more a workaround than a useable check for the current git version...

  • PyGIT.py

    TracGit-0.11.0.2-py2.6.mod/tracext/git # diff -u PyGIT.py PyGIT.py.orig 
    old new  
    1515from __future__ import with_statement
    1616
    1717import os, re, sys, time, weakref
    18 from subprocess import *
    1918from collections import deque
    2019from functools import partial
    2120from threading import Lock

this does the job for me, I can than use this plugin right now... pls will free to make a real patch for that bug. I will test it

Changed 13 years ago by cornbob@…

Attachment: PyGIT.py.patch added

tracext/git/PyGIT.py.patch

comment:22 Changed 9 years ago by Ryan J Ollos

Resolution: wontfix
Status: reopenedclosed

GitPlugin is deprecated. Please upgrade to Trac 1.0 and use TracGit.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Herbert Valerio Riedel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.