question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with running under another virtualenv + fish shell and a workaround

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Apr 11, 2016

Can confirm fixed:

asottile@work /t/foo> source venv/bin/activate.fish 
(venv) asottile@work /t/foo> pip install pre-commit==0.7.6
...
Installing collected packages: pyyaml, aspy.yaml, virtualenv, functools32, jsonschema, cached-property, nodeenv, ordereddict, pre-commit
Successfully installed aspy.yaml-0.2.2 cached-property-1.3.0 functools32-3.2.3.post2 jsonschema-2.5.1 nodeenv-0.13.6 ordereddict-1.1 pre-commit-0.7.6 pyyaml-3.11 virtualenv-15.0.1
(venv) asottile@work /t/foo> pre-commit run --all-files
Check Yaml...............................................................Failed
hookid: check-yaml

/home/asottile/.pre-commit/repoMVYdJO/py_env-default/bin/activate: line 61: basename: command not found
bash: xargs: command not found

(venv) asottile@work /t/foo> pip install pre-commit==0.8.0
...
Successfully installed pre-commit-0.8.0 pyterminalsize-0.1.0
(venv) asottile@work /t/foo> pre-commit run --all-files
Check Yaml...............................................................Passed
1reaction
asottilecommented, Apr 2, 2016

Fortunately, I’m currently factoring out bash and activate scripts entirely in my latest pull request so this should just magically fix itself!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get virtualenv to work with fish shell?
To deactivate, just ctrl-d or exit . Another solution, which does not invoke a child shell. Save this answer. Show activity on this...
Read more >
Fish Shell - Virtualenv path not prepended to PATH
I have this problem where when I activate a python virtual env, via >pipenv shell , the virtual env path is slotted into...
Read more >
User Guide — virtualenv 16.7.11 documentation
For some shells (e.g. the original Bourne Shell) you may need to use the . command, when source does not exist. There are...
Read more >
Pycharm Terminal fails to activate virtual env
I create a new project, selecting the option to create a new environment using Virtualenv. Once the project is created, I check the...
Read more >
Frequently Asked Questions — Ansible Documentation
See Ansible might be running slow if libyaml is not available for hints on how to improve this. How can I set the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found