Can't run git from python


I can’t run any git-related commands from within python (using subprocess and os modules).
Git works fine in the regular shell.

import subprocess["git", "status"])
# shows:
#    git: /nix/store/...-glib-2.33-59/lib/ version `GLIBC_@.34' not found (required by /nix/store/...-gcc-11.3.0-lib/lib/

import os
os.system("git status")
# also doesn't work

Git DOES work in already-created repls, but any new repls I create do this. (If I fork an already-created repl, it still works.)

I’m not sure how to help with this but you can consider using alternative approaches to interact with Git in Python, such as utilizing Git Python libraries like gitpython or pygit2.

I have tried using GitPython, however as soon as I import it it gives the same error.

I think the error suggests that the version of GLIBC required by the GCC library is not available on your system.

1 Like

It sounds like I need to update my GLIBC. However, on Replit installing and upgrading things is not possible, as it requires sudo access.
I saw these instructions on how to update GLIBC: 14.04 - Upgrading glibc - Ask Ubuntu

Look for upgrading it on Nix, as that’s replit’s package manager.

I’m not sure how to do that… I searched for how to update glibc using nix and replit nix update glibc and found no helpful results.
(By the way, my solution to the problem was to pipe git into my program like git status | python3