zyrikby / pyenv-pip-upgrade

Upgrade all packages to the latest versions in pyenv environments
Other
8 stars 4 forks source link

[POTENTIAL BUG] Cannot update specific virtualenv, tab completion is producing unexpected results #2

Open limsammy opened 2 years ago

limsammy commented 2 years ago

First of all, this is an awesome plugin.

To the issue:

I cannot seem to specify a specific virtualenv. I have many virtualenv's managed with pyenv so I cannot test the --all option to see if it is an issue with something in my global environment.

Errors:

$ pyenv pip-upgrade 3.9.0/envs/siemens_po-fastapi-nano                                                                                                                                         
/Users/red_rocket/.pyenv/plugins/pyenv-pip-upgrade/bin/pyenv-pip-upgrade: line 107: pyenvs_to_update[@]: unbound variable

Worth noting calling the command with no arguments returns a similar error:

$ pyenv pip-upgrade                                                                                                                                                                            
/Users/red_rocket/.pyenv/plugins/pyenv-pip-upgrade/bin/pyenv-pip-upgrade: line 80: $1: unbound variable

Also see number 5 below using full path as arg instead, outputs different error

Reproducing:

  1. Ensuring plugin installed successfully by checking if --help arg
$ pyenv pip-upgrade --help                                                                                                                                                                     
Usage: pyenv pip-upgrade [OPTIONS] <pyenv_env1> [<pyenv_env2> ...]
       pyenv pip-upgrade [OPTIONS] --all

This command update all packages to the latest versions of particular or all
pyenv environments excluding system. By default, pip-upgrade update all
outdated packages of an environment at once. New pip versions will generate an
error if the environment contains packages with conflicting dependencies. In
this case, you can add option '--sequential' to update packages sequentially,
however, the lately updated package will have precedence in this case
overriding the dependencies of the packages updated before.

ARGUMENTS:
  --all - to update all environments

OPTIONS:
  --sequential - update all outdated packages one by one
  1. Attempting tab completion (seems treat each env as an entire block, perhaps related to zsh)

out

  1. Attempting to run on single environment as per README example:
$ pyenv pip-upgrade 3.9.0/envs/siemens_po-fastapi-nano                                                                                                                                         
/Users/red_rocket/.pyenv/plugins/pyenv-pip-upgrade/bin/pyenv-pip-upgrade: line 107: pyenvs_to_update[@]: unbound variable
  1. Listing all envs (from your blog post)
$ ls -al ~/.pyenv/versions/                                                                                                                                                                    
total 0
drwxr-xr-x 26 red_rocket staff 832 Sep 10 16:53 .
drwxr-xr-x  7 red_rocket staff 224 Sep 10 17:08 ..
drwxr-xr-x  7 red_rocket staff 224 May 11  2020 3.8.2
drwxr-xr-x  7 red_rocket staff 224 Jun 29 15:49 3.9.0
lrwxr-xr-x  1 red_rocket staff  48 May 20  2020 JCA -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/JCA
lrwxr-xr-x  1 red_rocket staff  53 May 19  2020 biofrost -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/biofrost
lrwxr-xr-x  1 red_rocket staff  53 Aug 22  2020 claviate -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/claviate
lrwxr-xr-x  1 red_rocket staff  57 Aug 25 15:05 claviate-api -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/claviate-api
lrwxr-xr-x  1 red_rocket staff  62 Aug 25 14:38 claviate-platform -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/claviate-platform
lrwxr-xr-x  1 red_rocket staff  71 Sep  3 15:41 claviate-platform-detector -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/claviate-platform-detector
lrwxr-xr-x  1 red_rocket staff  57 Aug 27  2020 claviate_api -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/claviate_api
lrwxr-xr-x  1 red_rocket staff  51 Sep 18  2020 conmet -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/conmet
lrwxr-xr-x  1 red_rocket staff  57 May 11  2020 django-learn -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/django-learn
lrwxr-xr-x  1 red_rocket staff  51 May 15  2020 fp_pwn -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/fp_pwn
lrwxr-xr-x  1 red_rocket staff  53 Aug 17  2020 intelowl -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/intelowl
lrwxr-xr-x  1 red_rocket staff  55 Jun  1  2020 learn_kube -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/learn_kube
lrwxr-xr-x  1 red_rocket staff  55 Aug 25 04:49 md_to_conf -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/md_to_conf
lrwxr-xr-x  1 red_rocket staff  72 Aug 31 00:29 metaltoad-claviate-platform -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/metaltoad-claviate-platform
lrwxr-xr-x  1 red_rocket staff  60 May 12  2020 news_aggregator -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/news_aggregator
lrwxr-xr-x  1 red_rocket staff  48 Sep  3 12:07 opb -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/opb
lrwxr-xr-x  1 red_rocket staff  55 Sep  8 20:17 siemens_po -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/siemens_po
lrwxr-xr-x  1 red_rocket staff  68 Sep 10 16:53 siemens_po-fastapi-nano -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/siemens_po-fastapi-nano
lrwxr-xr-x  1 red_rocket staff  55 May 31  2020 socialscan -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/socialscan
lrwxr-xr-x  1 red_rocket staff  51 Aug 31 14:46 thales -> /Users/red_rocket/.pyenv/versions/3.9.0/envs/thales
lrwxr-xr-x  1 red_rocket staff  60 May 23  2020 world_destroyer -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/world_destroyer
lrwxr-xr-x  1 red_rocket staff  53 May 31  2020 x-docker -> /Users/red_rocket/.pyenv/versions/3.8.2/envs/x-docker
  1. Attempting to use the full path to the env as input arg returns same error
$ pyenv pip-upgrade /Users/red_rocket/.pyenv/versions/3.9.0/envs/siemens_po-fastapi-nano                                                                                                       

[ERROR]: Invalid arguments detected: /Users/red_rocket/.pyenv/versions/3.9.0/envs/siemens_po-fastapi-nano
Usage: pyenv pip-upgrade [OPTIONS] <pyenv_env1> [<pyenv_env2> ...]
       pyenv pip-upgrade [OPTIONS] --all

This command update all packages to the latest versions of particular or all
pyenv environments excluding system. By default, pip-upgrade update all
outdated packages of an environment at once. New pip versions will generate an
error if the environment contains packages with conflicting dependencies. In
this case, you can add option '--sequential' to update packages sequentially,
however, the lately updated package will have precedence in this case
overriding the dependencies of the packages updated before.

ARGUMENTS:
  --all - to update all environments

OPTIONS:
  --sequential - update all outdated packages one by one

Again, this plugin looks incredible, and would love to help contribute if this is some sort of environment-specific issue (zsh, osx, etc.)

EDIT: Also from your blog post I have used pyenv versions --bare --skip-aliases and attempted to use that output as an arg, same error.

zyrikby commented 2 years ago

@limsammy First of all, thank you for your kind words and the submitted issue!

Actually, I had a pretty outdated version of pyenv on my machine. I have updated it to the latest (2.0.6-7) and checked if I can reproduce the issue. Unfortunately, on my machine everything still works fine.

However, I've tried to investigate what can be the problem in your case. First of all, it seems that virtualenv plugin is not working correctly for some setups after upgrading to pyenv v2 (pyenv corresponding issue and pyenv-virtualenv issue). Try to use the workarounds provided in these issues.

Also, could you please check if the command pyenv versions (without additional flags) work fine on your setup?

sunflailOOH commented 2 years ago

I also ran into this issue - escaping the expansion of the list on line 107 did the trick for me, I'm unsure if there should be other escapes on the other quoted expansions so replying here instead of submitting a PR, leaving that up to you @zyrikby - fantastic work! original: if ! elementIn "${argument}" "${pyenvs_to_update[@]}"; then escaped: if ! elementIn "${argument}" "\${pyenvs_to_update[@]}"; then

zyrikby commented 2 years ago

@sunflailOOH Do you also use Mac?