Issues with running under another virtualenv + fish shell and a workaround
See original GitHub issueI am using fish shell + project virtualenv.
Whenever I activate my project’s virtualenv, running pre-commit would fail, with strange errors like `basename: command not found’.
sh /Users/ustun/.pre-commit/repoUMoyOJ/py_env-default/bin/activate: line 61: basename: command not found bash: xargs: command not found
However, after deactivating the virtualenv, pre-commit would run properly.
It turns out one of the reasons is the usage of bash -c
.
fish sets path as space delimited values: /usr/bin /usr/local/bin as opposed to /usr/bin:/usr/local/bin.
When we run bash -c ‘echo $PATH’ for example, it still receives the $PATH of fish, not $bash.
I went ahead and replaced in my local pre-commit scripts everything that refers to bash with fish, and changes &&'s to ;
This fixed it for me. Just documenting in case it helps another person.
I’m still not sure why deactivating the project virtualenv helped, I guess there’s some incompatibility by running activate.fish (fish specific script for venv) and then activate (bash specific script for venv).
I also tried bash -l -c to get a clean bash environment, but that didn’t help.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Can confirm fixed:
Fortunately, I’m currently factoring out bash and activate scripts entirely in my latest pull request so this should just magically fix itself!