I can not use bench --version in home/myusername folder

I can not use bench --version in my home/myusername folder but I can use that command in home/myusername/trial it works in that directory.

I use wsl ubuntu.

i got this error in home/myusername
“Traceback (most recent call last):
File “/home/enginc4n/.local/bin/bench”, line 8, in
sys.exit(cli())
^^^^^
File “/home/enginc4n/.local/lib/python3.12/site-packages/bench/cli.py”, line 74, in cli
cmd_from_sys = get_cmd_from_sysargv()
^^^^^^^^^^^^^^^^^^^^^^
File “/home/enginc4n/.local/lib/python3.12/site-packages/bench/utils/init.py”, line 581, in get_cmd_from_sysargv
if sys_argv.index(arg) == 0 and arg in Bench(”.“).apps:
^^^^^^^^^^
File “/home/enginc4n/.local/lib/python3.12/site-packages/bench/bench.py”, line 67, in init
self.apps = BenchApps(self)
^^^^^^^^^^^^^^^
File “/home/enginc4n/.local/lib/python3.12/site-packages/bench/bench.py”, line 177, in init
self.initialize_apps()
File “/home/enginc4n/.local/lib/python3.12/site-packages/bench/bench.py”, line 284, in initialize_apps
self.apps.remove(“frappe”)
ValueError: list.remove(x): x not in list”

Getting same error.

Did

 sudo pip3 uninstall bench
 sudo pip3 install git+https://github.com/frappe/bench.git@v5.22.9
 bench --version
 sudo pip3 uninstall bench
 sudo pip3 install git+https://github.com/frappe/bench.git@v5.18.0
 bench --version

for each bench --version, getting:

~$ bench --version
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bench/cli.py", line 74, in cli
    cmd_from_sys = get_cmd_from_sysargv()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bench/utils/__init__.py", line 554, in get_cmd_from_sysargv
    if sys_argv.index(arg) == 0 and arg in Bench(".").apps:
                                           ^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bench/bench.py", line 67, in __init__
    self.apps = BenchApps(self)
                ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bench/bench.py", line 175, in __init__
    self.initialize_apps()
  File "/usr/local/lib/python3.11/dist-packages/bench/bench.py", line 282, in initialize_apps
    self.apps.remove("frappe")
ValueError: list.remove(x): x not in list

what could be the issue, and how solution be found?

if you have more than one bench that installed in your system, you have to use another folder for other branches. I solved it like that

There is a single bench installed system wide.

i am not good at frappe but you can try to create a folder - the folder name is not that important- then you can try to call your frappe commands in that folder. That way my solution for that problem

I removed system wise frappe-bench, and tried to install in virtual environment.

frappe@cc:~$ which bench
# Nothing in output, so bench is not installed.
frappe@cc:~$ bench
-bash: bench: command not found
frappe@cc:~$ python3 -m venv venvRai
frappe@cc:~$ source venvRai/bin/activate
(venvRai) frappe@cc:~$ pip3 install frappe-bench

It installled following packages:

Successfully installed MarkupSafe-3.0.2 certifi-2024.8.30 charset-normalizer-3.4.0
click-8.1.7 frappe-bench-5.22.9 gitdb-4.0.11 gitpython-3.1.43 honcho-2.0.0 idna-3.10 
jinja2-3.1.4 python-crontab-2.6.0 python-dateutil-2.9.0.post0 requests-2.32.3 
semantic-version-2.10.0 six-1.16.0 smmap-5.0.1 urllib3-2.2.3
(venvRai) frappe@cc:~$ 

But still faced the same issue:

(venvRai) frappe@cc:~$ which bench
/home/frappe/venvRai/bin/bench
(venvRai) frappe@cc:~$ bench init frappe-bench
Traceback (most recent call last):
  File "/home/frappe/venvRai/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/cli.py", line 74, in cli
    cmd_from_sys = get_cmd_from_sysargv()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/utils/__init__.py", line 581, in get_cmd_from_sysargv
    if sys_argv.index(arg) == 0 and arg in Bench(".").apps:
                                           ^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 67, in __init__
    self.apps = BenchApps(self)
                ^^^^^^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 177, in __init__
    self.initialize_apps()
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 284, in initialize_apps
    self.apps.remove("frappe")
ValueError: list.remove(x): x not in list
(venvRai) frappe@cc:~$ 

and same for bench --version:


(venvRai) frappe@cc:~$ bench --version
Traceback (most recent call last):
  File "/home/frappe/venvRai/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/cli.py", line 74, in cli
    cmd_from_sys = get_cmd_from_sysargv()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/utils/__init__.py", line 581, in get_cmd_from_sysargv
    if sys_argv.index(arg) == 0 and arg in Bench(".").apps:
                                           ^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 67, in __init__
    self.apps = BenchApps(self)
                ^^^^^^^^^^^^^^^
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 177, in __init__
    self.initialize_apps()
  File "/home/frappe/venvRai/lib/python3.11/site-packages/bench/bench.py", line 284, in initialize_apps
    self.apps.remove("frappe")
ValueError: list.remove(x): x not in list

I created frapp-bench, and in that folder I did:

(venvRai) frappe@cc:~/frappe-bench$ pip3 install frappe                                                                        
Collecting frappe                                                                                                              
  Using cached frappe-0.0.1-py3-none-any.whl (1.3 kB)                                                                          
Installing collected packages: frappe                                                                                          
Successfully installed frappe-0.0.1 
(venvRai) frappe@cc:~/frappe-bench$ frappe --install hs.rai     
-bash: frappe: command not found
(venvRai) frappe@cc:~/frappe-bench$ cd ..
(venvRai) frappe@cc:~$ cd -
/home/frappe/frappe-bench
(venvRai) frappe@cc:~/frappe-bench$ bench --version
5.22.9
(venvRai) frappe@cc:~/frappe-bench$ cd ..
(venvRai) frappe@cc:~$ bench --version
Traceback (most recent call last):
  File "/home/frappe/venvRai/bin/bench", line 8, in <module>
    sys.exit(cli())

[i.e. same isue, outside frappe-bench folder]

Then I was able to do bench init:

(venvRai) frappe@cc:~/frappe-bench$ bench init fb
Setting Up Environment
$ python3 -m venv env
$ /home/frappe/frappe-bench/fb/env/bin/python -m pip install --quiet --upgrade pip
$ /home/frappe/frappe-bench/fb/env/bin/python -m pip install --quiet wheel
Getting frappe

Still I am not clear how it worked, and why it worked :wink:

If it works do not touch it :smiley:

1 Like