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 to run, I get the following error
/usr/local/bin/pyenv:94: command not found: shopt
My default shell is the latest MacOS
's default shell i.e. zsh
.
On searching for the fix, I found out it has something to do with bash
interfering with the zsh
.
My default shell is zsh
in settings, the contents of ~/.bash_profile
, /etc/profile
& /etc/bashrc
are all commented out but I am still having the issue.
My OS Verion is: 10.15.4
.
I tried reinstalling pyenv
as well but I am getting the same error.
I am unable to run ANY pyenv
related command.
Edit 1
I already have these lines in my .zshrc
as per the documentation, but as you can see, even this run a command pyenv root
and this gives me the same shopt
error.
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$(pyenv root)/shims:$(pyenv root)/completions/pyenv.zsh:$PATH"
Edit 2
Run
env
and add the output in your question
TMPDIR=/var/folders/gm/t0h6v8jx4bqd6cj73_k27myw0000gp/T/
XPC_FLAGS=0x0
TERM_PROGRAM_VERSION=433
TERM_PROGRAM=Apple_Terminal
XPC_SERVICE_NAME=0
TERM_SESSION_ID=55A65E3A-9B71-4C8A-81B8-0170EEAE3DCE
TERM=xterm-256color
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.j6zkqCw6Of/Listeners
SHELL=/bin/zsh
HOME=/Users/abc
LOGNAME=abc
USER=abc
PATH=/usr/local/opt/[email protected]/bin:/Users/saadali/Library/Python/3.7/bin:/usr/local/Cellar/[email protected]/9.6.16/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/abc/bin:/usr/local/opt/rabbitmq/sbin
SHLVL=1
PYTHONPATH=
LANGUAGE=en_US.UTF-8
port=
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
CPPFLAGS=-I/usr/local/opt/[email protected]/include
LDFLAGS=-L/usr/local/opt/[email protected]/lib
CFLAGS=-I/usr/local/opt/[email protected]/include
LANG=en_US.UTF-8
LC_MESSAGES=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8
_=/usr/bin/env
Edit 3
Please read this chat first before recommending to try something, as I might have already tried it. Chat starts at Apr 29 02:01 UTC +5
and then moves to a thread.
Edit 4
After setting PYENV_DEBUG=1
, here the output
(vmds) saadali@A006-00276 ~ :~$ pyenv
+ [:22] enable -f /../libexec/pyenv-realpath.dylib realpath
+ [:29] [ -z '' ']'
+ [:31] READLINK=+ [:31] type -p greadlink readlink
+ [:31] READLINK=+ [:31] head -1
+ [:31] READLINK='greadlink not found'
+ [:32] [ -n 'greadlink not found' ']'
+ [:57] [ -z '' ']'
+ [:58] PYENV_ROOT=/Users/abc/.pyenv
+ [:62] export PYENV_ROOT
+ [:65] [ -z '' ']'
+ [:66] [ -n '' ']'
+ [:82] [ -z '' ']'
+ [:83] PYENV_DIR=/Users/abc
+ [:86] [ ! -d /Users/abc ']'
+ [:86] [ ! -e /Users/abc ']'
+ [:90] PYENV_DIR=+ [:90] cd /Users/abc
+ [:90] echo /Users/abc
+ [:90] PYENV_DIR=/Users/abc
+ [:91] export PYENV_DIR
+ [:94] shopt -s nullglob
/usr/local/bin/pyenv:94: command not found: shopt
/usr/local/bin/pyenv
? – Bersaglierewhich shopt
? – Ballocksenv
and add the output of the same to your question – Croup#!/usr/bin/env bash
but this problem happens in bash terminal too. – Pothookshopt
is an internalbash
command, onzsh
output ofwhich shopt
is of course command not found, onbash
terminal it returns nothing as it's not a command, but if I do simpleshopt
, it shows some shopt related stuff. – Pothook/usr/bin/env bash
really executing/usr/bin/bash
? What happens if you change the shebang in your pyenv executable to#!/usr/bin/bash
? Also, remember you can run pyenv with debug output by settingPYENV_DEBUG=1
. – Government/usr/bin/env bash
to/bin/bash
worked for me. But to made it work, I had to change my default terminal shell tobash
instead ofzsh
and I had been using it withzsh
and it used to work fine. Also, running/usr/bin/evn bash
works fine in myzsh
terminal. – Pothookpyenv --version
worked butpyenv ls
did not work, I did$ which bash
and then seeing the output, I didls -l /usr/local/bin/bash
which showed me a symbolic link/usr/local/bin/bash -> /bin/zsh
should this link be here? Also making the change in the above comment made some commands work and some not, what kind of behaviour is this? – Pothookbash
command, e.g. some wrong symlinks? That said, pyenv should work fine (at least not choke on shopt) when you invoke it directly with/bin/bash /usr/local/bin/pyenv
. – Government