justinmayer / virtualfish

Fish shell tool for managing Python virtual environments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`vf upgrade` yields error when virtual environment does not exist

ammgws opened this issue · comments

  • I am using Fish shell version 3.1 or higher.

  • I am using Python version 3.6 or higher.

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • If related to a plugin, I prefixed the issue title with the name of the plugin.

  • OS version and name: Arch Linux

  • Fish shell version: 3.6.1

  • VirtualFish version: 2.5.5

Issue

>vf upgrade doesnotexist
doesnotexist is broken. Rebuilding…
fish: Unknown command: /home/ammgws/.local/share/virtualenvs/doesnotexist/bin/python
in command substitution
	called on line 603 of file /usr/lib/python3.11/site-packages/virtualfish/virtual.fish
in function '__vf_upgrade' with arguments 'doesnotexist'
	called on line 1 of file /usr/lib/python3.11/site-packages/virtualfish/virtual.fish
in function 'vf' with arguments 'upgrade doesnotexist'
/usr/lib/python3.11/site-packages/virtualfish/virtual.fish (line 603): Unknown command
            set -l old_py_fv ($venv_path/bin/python -V | string split " ")[2]
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
in function '__vf_upgrade' with arguments 'doesnotexist'
	called on line 1 of file /usr/lib/python3.11/site-packages/virtualfish/virtual.fish
in function 'vf' with arguments 'upgrade doesnotexist'
Argument is not a number: '.'
/usr/lib/python3.11/site-packages/virtualfish/virtual.fish (line 611): 
            if test "$old_py_mv" -ne "$new_py_mv"
               ^
in function '__vf_upgrade' with arguments 'doesnotexist'
	called on line 1 of file /usr/lib/python3.11/site-packages/virtualfish/virtual.fish
in function 'vf' with arguments 'upgrade doesnotexist'
Upgrading doesnotexist from  to 3.11.5
ln: failed to create symbolic link '/home/ammgws/.local/share/virtualenvs/doesnotexist/bin/python': No such file or directory
ln: failed to create symbolic link '/home/ammgws/.local/share/virtualenvs/doesnotexist/bin/python3': No such file or directory
ln: failed to create symbolic link '/home/ammgws/.local/share/virtualenvs/doesnotexist/bin/python3.11': No such file or directory
find: ‘/home/ammgws/.local/share/virtualenvs/doesnotexist’: No such file or directory
rm: missing operand
Try 'rm --help' for more information.

Expected behaviour

Check if valid venv and exit earlier. Especially since the vf upgrade --help text does say it's for existing venvs: "Purpose: Upgrades existing virtual environment(s)"

Perhaps add a check around here or in the following for loop:

set venv_list $argv