Skip to content Skip to sidebar Skip to footer

Pyenv Giving Shopt Command Not Found Error On Macos

I have been using pyenv for managing python versions and virtual environments on my mac for some time now. Recently I reinstalled pyenv and since then on every pyenv command I try

Solution 1:

According to your info and comments it seems your issue has 3 causes working hand in hand:

  1. pyenv is a bash (and bash-only) script with a shebang line #!/usr/bin/env bash
  2. /usr/local/bin comes before /usr/bin or /bin in your PATH, so executables therein are picked up first by /usr/bin/env (desired behaviour, especially when using homebrew)
  3. /usr/local/bin/bash is symlinked to /bin/zsh!?!

So in the end you are running pyenv with zsh, which, albeit being a close replacement for bash, doesn't know about shopt and therefore chokes. I don't know why the symlink is in place, but it shouldn't, because zsh is not a fully compatible drop-in replacement for bash.

I'd suggest to

  1. (in case you are using homebrew) Check if you have/had bash installed through homebrew (which was later somehow replaced by a symlink to zsh):

    # shows only top-level packages (directly installed)
    brew leaves        
    
    # shows *all* packages with dependency tree
    brew deps --tree--installed

    And uninstall bash if not required anymore (which should then remove /usr/local/bin/bash).

  2. Either delete or at least rename the culprit:

    mv /usr/local/bin/bash /usr/local/bin/bash_link_to_zsh

    Or, if some program requires /usr/local/bin/bash to be in place, just have it point to /bin/bash.

Post a Comment for "Pyenv Giving Shopt Command Not Found Error On Macos"