Pipenv: Add way to force a particular environment shell

Created on 24 Oct 2017  Â·  5Comments  Â·  Source: pypa/pipenv

Arch recommends users to keep a bash-compatible shell as default [0]. I'm using the method of execing fish from my .bashrc.

pipenv fails on pipenv shell, apparently because it thinks that the bash activate should be executed

Spawning environment shell (/bin/bash). Use 'exit' to leave.
~/s/tmp î‚° source /home/me/.local/share/virtualenvs/tmp-yq4UYSVl/bin/activate
~/.local/share/virtualenvs/tmp-yq4UYSVl/bin/activate (line 23): Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'.
    if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
                          ^
from sourcing file ~/.local/share/virtualenvs/tmp-yq4UYSVl/bin/activate
    called on standard input

source: Error while reading file “/home/me/.local/share/virtualenvs/tmp-yq4UYSVl/bin/activate”

If I replace activate with activate.fish, the pipenv works as expected.

Could there be a flag or, even better yet, a config option to force the default environment shell?

[0] https://wiki.archlinux.org/index.php/Fish#Not_setting_fish_as_default_shell

Describe you environment
  1. OS Type
    Linux tp 4.13.7-1-ARCH #1 SMP PREEMPT Sat Oct 14 20:13:26 CEST 2017 x86_64 GNU/Linux
  2. Python version: $ python -V
    Python 3.6.2
  3. Pipenv version: $ pipenv --version
    pipenv, version 8.2.7
Linux Discussion Type

Most helpful comment

@kehugter in compat mode your shell is determined by the SHELL environment variable, so you can just export $SHELL in your .bashrc or run the subshell with SHELL=/usr/bin/fish pipenv shell and it should work. Let me know if this helps

All 5 comments

Huh, maybe an environment variable? @kennethreitz @nateprewitt or @techalchemy any thoughts?

@kehugter in compat mode your shell is determined by the SHELL environment variable, so you can just export $SHELL in your .bashrc or run the subshell with SHELL=/usr/bin/fish pipenv shell and it should work. Let me know if this helps

@techalchemy I completely forgot about that, been working on windows too long.....

@techalchemy

export $SHELL in your .bashrc

thanks, that works.

If I understand it correctly, this approach is fine on a local machine but would break the $SHELL env var that Arch expects in remote non-login non-interactive shells:

https://blog.flowblok.id.au/static/images/shell-startup-actual.png

An edge case perhaps worth considering and documenting.

Yes, as with all shell configurations you should include interactive settings in interactive shells only. That information _is_ mentioned in the docs in the context of fish, but as a user who is concerned about edge cases of people trying to run an interactive pipenv shell on a non interactive shell, well that use case isn’t possible so you shouldn’t change the variable. If you want to be safe however you can follow the bash instructions about testing for interactivity before setting the value: see here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacek-jablonski picture jacek-jablonski  Â·  3Comments

xi picture xi  Â·  3Comments

marc-fez picture marc-fez  Â·  3Comments

hynek picture hynek  Â·  3Comments

jeyraof picture jeyraof  Â·  3Comments