Title: [Bug] GitCommandNotFound when executing repo.git.execute on macOS · Issue #2016 · gitpython-developers/GitPython · GitHub
Open Graph Title: [Bug] GitCommandNotFound when executing repo.git.execute on macOS · Issue #2016 · gitpython-developers/GitPython
X Title: [Bug] GitCommandNotFound when executing repo.git.execute on macOS · Issue #2016 · gitpython-developers/GitPython
Description: Describe the bug When executing repo.git.execute with string-type arguments on macOS, it throws a GitCommandNotFound exception: Traceback (most recent call last): File "/Users/macuser/.pyenv/versions/3.12.2/lib/python3.12/site-packages/g...
Open Graph Description: Describe the bug When executing repo.git.execute with string-type arguments on macOS, it throws a GitCommandNotFound exception: Traceback (most recent call last): File "/Users/macuser/.pyenv/versio...
X Description: Describe the bug When executing repo.git.execute with string-type arguments on macOS, it throws a GitCommandNotFound exception: Traceback (most recent call last): File "/Users/macuser/.pyenv/v...
Opengraph URL: https://github.com/gitpython-developers/GitPython/issues/2016
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] GitCommandNotFound when executing repo.git.execute on macOS","articleBody":"**Describe the bug**\nWhen executing repo.git.execute with string-type arguments on macOS, it throws a GitCommandNotFound exception:\n```\nTraceback (most recent call last):\n File \"/Users/macuser/.pyenv/versions/3.12.2/lib/python3.12/site-packages/git/cmd.py\", line 1262, in execute\n proc = safer_popen(\n ^^^^^^^^^^^^\n File \"/Users/macuser/.pyenv/versions/3.12.2/lib/python3.12/subprocess.py\", line 1026, in __init__\n self._execute_child(args, executable, preexec_fn, close_fds,\n File \"/Users/macuser/.pyenv/versions/3.12.2/lib/python3.12/subprocess.py\", line 1953, in _execute_child\n raise child_exception_type(errno_num, err_msg, err_filename)\nFileNotFoundError: [Errno 2] No such file or directory: 'git log -n 1'\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/Users/macuser/test.py\", line 36, in \u003cmodule\u003e\n cmd = repo.git.execute(\"git log -n 1\")\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/macuser/.pyenv/versions/3.12.2/lib/python3.12/site-packages/git/cmd.py\", line 1275, in execute\n raise GitCommandNotFound(redacted_command, err) from err\ngit.exc.GitCommandNotFound: Cmd('g') not found due to: FileNotFoundError('[Errno 2] No such file or directory: 'git log -n 1'')\n```\nI have installed git and it works well on other commands, only repo.git.execute doesn't work'\n\nThe error only occurs when passing a string-type argument to repo.git.execute\n\nWorks correctly when using string array arguments\n\nWorks correctly when using shell=True argument\n\nfor example:\n\n```python\n# Failing case (string argument)\nrepo.git.execute(\"git log -n 1\") # Throws exception\n\n# Working case (array argument)\nrepo.git.execute([\"git\", \"log\", \"-n\", \"1\"]) # Executes successfully\n\n# Working case (array argument)\nrepo.git.execute(\"git log -n 1\", shell=True) # Executes successfully\n```\n\n**Environment**\n- Python version: 3.12\n- GitPython version: 3.1.43\n- Operating System: macOS 14.3.1 (Sonoma)\n- Git version: 2.46.0\n- By the way, I'm using pyenv","author":{"url":"https://github.com/cloudskytian","@type":"Person","name":"cloudskytian"},"datePublished":"2025-03-19T08:55:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/2016/GitPython/issues/2016"}
| 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:c5defae0-9ebd-59fc-d4f9-66155144306b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D72:3244AB:112AC8E:171E99A:6969A8F5 |
| html-safe-nonce | 38a65175528918eada1f5623d066e861eed2f8e28929ccf15baacae1b7cabddf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDcyOjMyNDRBQjoxMTJBQzhFOjE3MUU5OUE6Njk2OUE4RjUiLCJ2aXNpdG9yX2lkIjoiMzA5MDYxNDU4OTMyMTE1NzAxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ca3346d9b4f21788933649d6523bc46ec18eb80fe6754784cc96a5daf1fb7f19 |
| hovercard-subject-tag | issue:2930960915 |
| 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/2016/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cad2f088172d2cbf0c5bcde95d355b22211a1a6307f35733b5b403e6acd15d34/gitpython-developers/GitPython/issues/2016 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cad2f088172d2cbf0c5bcde95d355b22211a1a6307f35733b5b403e6acd15d34/gitpython-developers/GitPython/issues/2016 |
| og:image:alt | Describe the bug When executing repo.git.execute with string-type arguments on macOS, it throws a GitCommandNotFound exception: Traceback (most recent call last): File "/Users/macuser/.pyenv/versio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cloudskytian |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| 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 | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width