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: togithub.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:209facf5-30cf-b425-42e0-0d0dcb304b5c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A4B8:2B7A56:373460:4E1CB6:696A4D58 |
| html-safe-nonce | 3612a58ed140f1b99ebb9cb6396d35fb9ed3e057652279fca8182a453540748e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNEI4OjJCN0E1NjozNzM0NjA6NEUxQ0I2OjY5NkE0RDU4IiwidmlzaXRvcl9pZCI6IjQzNTA5NDg4OTM2NDIwODM2NzIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e6c43f1a1667d72b2c353b3b02425a8292b0d600112d718d494145f6ba66bccc |
| 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 | 3f871c8e07f0ae1886fa8dac284166d28b09ad5bada6476fc10b674e489788ef |
| 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 | 63c426b30d262aba269ef14c40e3c817b384cd61 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width