Opened 16 years ago
Closed 10 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)
Change History (25)
Changed 16 years ago by
Attachment: | no_shell_exec.patch added |
---|
Changed 16 years ago by
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 16 years ago by
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 16 years ago by
Sadly this patch makes no difference here / Python 2.6 also
Trac[git_fs] ERROR: GitError: Could not retrieve GIT version
:(
comment:3 follow-up: 4 Changed 16 years ago by
I am having the exact same problem here. Patch doesn't work
I'm on Ubuntu 8.10
comment:4 Changed 16 years ago by
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 16 years ago by
I love you. With this patch, it finally started working for me. Thank you :)
comment:6 Changed 16 years ago by
Can anyone who hit this issue report on your OS and version of git?
comment:7 Changed 16 years ago by
The attached patch fixes the problem for me on:
openSUSE 11.1 git version 1.6.0.2 python 2.6
comment:8 Changed 16 years ago by
Cc: | douglas@… added; anonymous removed |
---|---|
Priority: | high → 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
comment:9 Changed 16 years ago by
Priority: | highest → 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.
comment:10 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
should be fixed now in 0.11 branch; please reopen ticket if this is not the case
comment:11 Changed 16 years ago by
Priority: | high → normal |
---|---|
Resolution: | fixed |
Severity: | blocker → normal |
Status: | closed → reopened |
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 16 years ago by
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 16 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:14 Changed 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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:16 Changed 15 years ago by
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
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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:19 follow-up: 20 Changed 14 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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 follow-up: 21 Changed 14 years ago by
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 Changed 14 years ago by
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 15 15 from __future__ import with_statement 16 16 17 17 import os, re, sys, time, weakref 18 from subprocess import *19 18 from collections import deque 20 19 from functools import partial 21 20 from 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
comment:22 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
GitPlugin is deprecated. Please upgrade to Trac 1.0 and use TracGit.
Patch which fixes the issue.