Open andyk opened 2 years ago
@nickjalbert any reason we should not pass shell=True
to subprocess.run()
in order to make sure our command behaves more like the user's shell?
Adding shell=True
seems to break a few tests, perhaps most importantly it breaks the test_vm_repl
test inside of the test_venv_management.py
file. I think the way the test fails might be more clear to understand if #364 was fixed.
Hmm, I don't know why shell=True
breaks tests. Off the top of my head, I don't know why it should behave differently (and, consequently, it seems like it should be fine to run with shell=True
). Something to investigate!
Including PATH in the env we pass to the
subprocess.run
causes mygit
to use/usr/local/git/etc/gitconfig
which refers to files that don't exist in my homedir (~/.gitcinclude
, `~/.gitignore, etc.).https://github.com/agentos-project/agentos/blob/4030b81ef1db4b86614e3d8e861eb8d95845edce/pcs/virtual_env.py#L214-L219
I verified this by running the following after activating virtualenv created by agentos for the agent:
which fails with:
the
~/.gitignore'
in the error is referring to a line in/usr/local/git/etc/gitconfig
.And then I run it again, but remove
/usr/local/bin
from the PATH in the command:...and the pip install runs fine.
Running the pip command directly in my bash shell works fine. That is, the following works fine (note that PATH is the same):
I believe the problem is that we are currently passing shell=False to
subprocess.run()
, and so git is behaving differently for that subprocess than it does for me inside my shell (i.e., git seems to be using that conf file/usr/local/git/etc/gitconfig
but not for my shell.I verified this by running the same python command inside the virtualenv as before, except i set
shell=True
and it succeeds: