Title: [GitPython >= 2.1.4] Can't import without git CLI · Issue #657 · gitpython-developers/GitPython · GitHub
Open Graph Title: [GitPython >= 2.1.4] Can't import without git CLI · Issue #657 · gitpython-developers/GitPython
X Title: [GitPython >= 2.1.4] Can't import without git CLI · Issue #657 · gitpython-developers/GitPython
Description: Description of Problem Since GitPython 2.1.4, the initial import git fails because it invokes the git CLI, raising a git.exc.GitCommandNotFound error. However, due to the chicken-and-egg nature of this import, it is impossible for one to...
Open Graph Description: Description of Problem Since GitPython 2.1.4, the initial import git fails because it invokes the git CLI, raising a git.exc.GitCommandNotFound error. However, due to the chicken-and-egg nature of ...
X Description: Description of Problem Since GitPython 2.1.4, the initial import git fails because it invokes the git CLI, raising a git.exc.GitCommandNotFound error. However, due to the chicken-and-egg nature of ...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/657
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[GitPython \u003e= 2.1.4] Can't import without git CLI","articleBody":"## Description of Problem\r\n\r\nSince GitPython 2.1.4, the initial `import git` fails because it invokes the git CLI, raising a `git.exc.GitCommandNotFound` error. However, due to the chicken-and-egg nature of this import, it is impossible for one to catch a `git.exc.GitCommandNotFound` error.\r\n\r\n## Steps to Reproduce\r\n\r\nInstall GitPython \u003e= 2.1.4 on a box without git installed on it. An easy way to do this is to launch a Cent 7 docker container (which does not come with git installed off the base image), and then install GitPython (first installing EPEL repo and pip for ease of installation).\r\n\r\n```\r\n% docker run --rm -it centos:7 bash\r\n[root@c1c079f693dc /]# yum --quiet -y install epel-release\r\nwarning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-9.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY\r\nPublic key for epel-release-7-9.noarch.rpm is not installed\r\nImporting GPG key 0xF4A80EB5:\r\n Userid : \"CentOS-7 Key (CentOS 7 Official Signing Key) \u003csecurity@centos.org\u003e\"\r\n Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5\r\n Package : centos-release-7-3.1611.el7.centos.x86_64 (@CentOS)\r\n From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7\r\n[root@c1c079f693dc /]# yum --quiet -y install python-pip\r\nwarning: /var/cache/yum/x86_64/7/epel/packages/python2-pip-8.1.2-5.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY\r\nPublic key for python2-pip-8.1.2-5.el7.noarch.rpm is not installed\r\nImporting GPG key 0x352C64E5:\r\n Userid : \"Fedora EPEL (7) \u003cepel@fedoraproject.org\u003e\"\r\n Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5\r\n Package : epel-release-7-9.noarch (@extras)\r\n From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7\r\n[root@c1c079f693dc /]# command -v git \u0026\u0026 echo git is installed || echo git is not installed\r\ngit is not installed\r\nroot@c1c079f693dc /]# pip install GitPython\r\nCollecting GitPython\r\n Downloading GitPython-2.1.5-py2.py3-none-any.whl (443kB)\r\n 100% |################################| 450kB 1.0MB/s\r\nCollecting gitdb2\u003e=2.0.0 (from GitPython)\r\n Downloading gitdb2-2.0.2-py2.py3-none-any.whl (63kB)\r\n 100% |################################| 71kB 2.1MB/s\r\nCollecting smmap2\u003e=2.0.0 (from gitdb2\u003e=2.0.0-\u003eGitPython)\r\n Downloading smmap2-2.0.3-py2.py3-none-any.whl\r\nInstalling collected packages: smmap2, gitdb2, GitPython\r\nSuccessfully installed GitPython-2.1.5 gitdb2-2.0.2 smmap2-2.0.3\r\nYou are using pip version 8.1.2, however version 9.0.1 is available.\r\nYou should consider upgrading via the 'pip install --upgrade pip' command.\r\n```\r\n\r\nNow attempt to import:\r\n\r\n```\r\n[root@c1c079f693dc /]# python -c 'import git'\r\nTraceback (most recent call last):\r\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/usr/lib/python2.7/site-packages/git/__init__.py\", line 45, in \u003cmodule\u003e\r\n from git.repo import Repo # @NoMove @IgnorePep8\r\n File \"/usr/lib/python2.7/site-packages/git/repo/__init__.py\", line 4, in \u003cmodule\u003e\r\n from .base import *\r\n File \"/usr/lib/python2.7/site-packages/git/repo/base.py\", line 31, in \u003cmodule\u003e\r\n from git.remote import Remote, add_progress, to_progress_instance\r\n File \"/usr/lib/python2.7/site-packages/git/remote.py\", line 190, in \u003cmodule\u003e\r\n class FetchInfo(object):\r\n File \"/usr/lib/python2.7/site-packages/git/remote.py\", line 219, in FetchInfo\r\n v = Git().version_info[:2]\r\n File \"/usr/lib/python2.7/site-packages/git/cmd.py\", line 461, in version_info\r\n return self._version_info\r\n File \"/usr/lib/python2.7/site-packages/git/cmd.py\", line 424, in __getattr__\r\n return LazyMixin.__getattr__(self, name)\r\n File \"/usr/lib/python2.7/site-packages/gitdb/util.py\", line 256, in __getattr__\r\n self._set_cache_(attr)\r\n File \"/usr/lib/python2.7/site-packages/git/cmd.py\", line 444, in _set_cache_\r\n version_numbers = self._call_process('version').split(' ')[2]\r\n File \"/usr/lib/python2.7/site-packages/git/cmd.py\", line 877, in _call_process\r\n return self.execute(call, **exec_kwargs)\r\n File \"/usr/lib/python2.7/site-packages/git/cmd.py\", line 602, in execute\r\n raise GitCommandNotFound(command, err)\r\ngit.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[Errno 2] No such file or directory')\r\n cmdline: git version\r\n```\r\n\r\nIf you then downgrade to before version 2.1.4, the import works fine since the initial import no longer seems to be trying to invoke the git CLI:\r\n\r\n```\r\n[root@c1c079f693dc /]# pip install 'GitPython\u003c2.1.4'\r\nCollecting GitPython\u003c2.1.4\r\n Downloading GitPython-2.1.3-py2.py3-none-any.whl (442kB)\r\n 100% |################################| 450kB 993kB/s\r\nRequirement already satisfied (use --upgrade to upgrade): gitdb2\u003e=2.0.0 in /usr/lib/python2.7/site-packages (from GitPython\u003c2.1.4)\r\nRequirement already satisfied (use --upgrade to upgrade): smmap2\u003e=2.0.0 in /usr/lib/python2.7/site-packages (from gitdb2\u003e=2.0.0-\u003eGitPython\u003c2.1.4)\r\nInstalling collected packages: GitPython\r\n Found existing installation: GitPython 2.1.5\r\n Uninstalling GitPython-2.1.5:\r\n Successfully uninstalled GitPython-2.1.5\r\nSuccessfully installed GitPython-2.1.3\r\nYou are using pip version 8.1.2, however version 9.0.1 is available.\r\nYou should consider upgrading via the 'pip install --upgrade pip' command.\r\n[root@c1c079f693dc /]# python -c 'import git'\r\n[root@c1c079f693dc /]#\r\n```","author":{"url":"https://github.com/terminalmage","@type":"Person","name":"terminalmage"},"datePublished":"2017-08-10T21:08:55.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/657/GitPython/issues/657"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ff807020-fe9f-d386-568a-aaf79d4c0799 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EA4:2C9A2F:527E7C:6DF64C:6969C893 |
| html-safe-nonce | 17b1d4179a9e8c4d47d12991fb106857ed6e4dfe0539026f218e0f9fb7d1c546 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUE0OjJDOUEyRjo1MjdFN0M6NkRGNjRDOjY5NjlDODkzIiwidmlzaXRvcl9pZCI6Ijg1MzYwNjYyOTM2MDMzNTQ3NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 22251cf211fc0928656e984013273877e78e35bd3f2430f4c1760f59453b10c0 |
| hovercard-subject-tag | issue:249477375 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gitpython-developers/GitPython/657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9d55fa55dc79af2fa68afdbfbddd59e3731a19e74dcce551805980174f419778/gitpython-developers/GitPython/issues/657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9d55fa55dc79af2fa68afdbfbddd59e3731a19e74dcce551805980174f419778/gitpython-developers/GitPython/issues/657 |
| og:image:alt | Description of Problem Since GitPython 2.1.4, the initial import git fails because it invokes the git CLI, raising a git.exc.GitCommandNotFound error. However, due to the chicken-and-egg nature of ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | terminalmage |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width