Upgrading to version-12 ... what about updating bench itself?

I am about to upgrade a version-11 instance to version-12.

as far as I know

$ bench update
$ bench switch-to-branch version-12 frappe erpnext --upgrade
$ bench update

should do the job.

being on bench version 5.0 currently (where 5.3 is the latest version apparently) I am wondering whether bench will update itself to 5.3 in that process above or whether it was recommended to update bench manually?

if that needs to be done separately …

  1. is it a bench update ran in a folder one level above the frappe-bench folder which updates bench?
  2. should I do that prior to updating frappe/erpnext or after?

re-execute the step when you initialize the frappe-bench
in my lab, it should be

pip3 install --user frappe-bench

you should change frappe-bench as your own value

thx for the feedback

  1. I have a running version-11 site. Are you sure this would not do any harm to that?
  2. where do I have to run this from? the home folder of my frappe user?
  3. pip3 --version gives me an pip3 can be installed with apt install python3-pip error. I am running on p3 though there is an ~/env/lib/python3.6/ folder which I believe proves that.

about my instance:

  • … installed via the easy install script about 2.5 years ago (version-11), python2
  • … migrated to python 3 (Dec 2019 I believe)
  • pip --version returns pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
  1. it is hard to ensure no problem, as check from forum it seem many conditions can cause update or change failure.
    I haven’t try v11 yet, I use v12 and upgrade to v13 without issue

  2. at the home user directory, eg. if user is frappe
    /home/frappe

  3. it depend on the OS I think, co-exist with python and python3 is possible.

pip seems out-of-date, you may get another warning of pip version.

if possible I always recommend do a DR backup before any action, since error can’t eliminate and no guarantee “error-free” in all environments.

Upgrading Bench:

Now that Bench 5.0+ is hosted on PyPi.org, you should be able to upgrade as follows:

# From any directory, does not matter which.

pip3 install frappe-bench --upgrade

This would upgrade you to Bench 5.3.0.

No application code (Frappe, ERPNext) code would be touched. You would still be on the same ERPnext version.

Only the Bench CLI code itself would be upgraded.

so, if I do not have pip3, I’d need to run an apt install python3-pip prior that, I guess

Yes. Although if you already have Bench installed, you should definitely have pip installed too.

If you’re running ERPNext with Python2, the command is just pip.

I think the answer to that may be that it was during the python 2 era when I installed the instance (using the easy install script). I have updated to python 3 when the time came.

I have noted, there is a pip3 entry in frappe-bench/env/bin there actually is a pip3 and a pip3.6 entry. Maybe I have to address that with the complete path and not just pip3 ...

Gotcha. For any machine, there are 3 possible locations where Python saves packages.

  1. If you install as normal user, Python packages are in $HOME/.local/lib/python3.x/site-packages/

  2. If you install as root, packages are in /usr/local/lib/python3.x/site-packages/
    (note: this may vary slightly between Linux distributions, or if you installed Python manually)

  3. When using Python Virtual Environments (which Frappe does), you’ll find them inside whatever virtual environment directory was created. In your case, ../frappe-bench/env/

You don’t want to mess with ../frappe-bench/env. That is ERPNext’s virtual environment. While Bench created that for you, the contents have nothing to do with “Bench code”.

My advice is this.

  1. Find your current Bench installation. You can identify where it’s located using
which bench
  1. Take a backup. Then remove that older Bench.
  • Remember not to touch your frappe-bench directory or contents at all!
  1. Install a fresh Bench app using Python3 and pip3:
pip3 install frappe-bench
  1. Verify it installed correctly
which bench
bench --version
  1. Change your working directory to your ../frappe-bench/ directory.
  2. Carry on and use Bench normally. All commands should be working fine. But Frappe and ERPNext themselves should be untouched.

Hopefully this makes sense. It’s a bit confusing because “Bench” is a separate app. But the default name of Frappe and ERPNext’s working directory is “frappe-bench”. Which is neither Bench, nor Frappe. :slight_smile:

I sometimes install my environment with a completely different name, instead of “frappe-bench”, to avoid confusion.

returns /usr/local/bin/bench (which is a file) and 4.1.0 as then bench version

installing bench with sudo /frappe-bench/env/pip3 install frappe-bench results into a new bench file in ~/frappe-bench/env/bin owned by root (same ownership as previous bench in /usr/local/bin)

however the verification with

which bench
bench --version

does not return any values besides Command ‘bench’ not found

$ sudo env/bin/bench --version
5.3.0

whithout sudo the installation did not go through and without sudo I get an error for env/bin/bench --version

I am wondering whether is just making the file location known but wouldn’t know how exacly. Or would it make sense to provide a specific location (like /usr/local/bin) with the installation?

Also I have noted, that there is a pip3.6 also available (not referred to by pip3). Does it make sense to use that instead pip3?

bench should run from the frappe-user (who has no root permissions) so I guess there may be something wrong with the installation via root to begin with

Hi @vrms,

TLDR → I believe that Bench now must be installed twice. First as a regular user. Then again as root user.

Explanation:
@bkm and I were discussing this last month. We discovered several challenges during v13 installation.

  • In Bench 4.0 and earlier, the official instructions for installing Bench was using pip’s “editable mode”. This was the 'pip3 install -e .' command.
  • Now, Bench is available on PyPi.org. So we install using pip3 install frappe-bench. This command downloads Bench from PyPi, and installs on our machines.

Here is the problem:

  • Bench sometimes must be root (because it does things with apt, systemd, ansible)
  • Bench sometimes must be a regular user (all the other commands)

Python’s package system can be…painful. Partly because interpretive languages have more moving parts. But also because Python does some magic with symlinks, PATH changes, has no .lock file, virtual environments, etc.

When I installed Bench as a regular user, I could not make it run successfully as root. I tried changing my PATH variables. I even tried manually installing Bench inside a virtual environment. No luck. Even when it appeared like I was successful, Bench would always fail later with a “module not found” error.

Nothing I tried allowed for installing Bench once. But running both as regular and root. :confused:

Recommendations

  1. Until someone provides a workaround, I think the easiest solution for you is installing Bench twice. Once as root, once as a regular user. I think this is awful, but it’s the only solution I have when installing from PyPi.

  2. Alternately, you can still install Bench the old way, in pip’s editable mode. Bench 5.0 will raise warnings about this, and tell you editable mode is not recommended. But it does work.

1 Like

sorry, I made a simple mistake. And I actually can access bench (without AND with sudo) by just addressing it right (~/frappe-bench/env/bin/bench instead of just bench). I guess that could be solved by editing the PATH as well.

I installed bench with sudo pip3 install frappe-bench

however I am running into toubles in the upgrade process (v11 → v12) then. I guess they are out of scope of this Topic.

Just one final thing … do you believe you need bench 5.x to upgrade v11 → v12 at all (which was the actual reason for this Topic to begin with)

I stepped back to the orignal point and did not do the manual bench upgrade, but tried the regular ERPNext upgrade process … in the middle of it I checked on which bench and got 5.0. It seems to be upgrage in the process as well at some point.

No, it’s not necessary for a v11 → v12.

The last time I installed bench, I did this out of confusion. Because I can’t do sudo bench setup production (err: ‘bench is not found’ when sudo).
So I did:

  • pip3 install --user frappe-bench
  • pip3 install frappe-bench
  • sudo pip3 install --user frappe-bench
  • sudo pip3 install frappe-bench

Hence maybe there were 4 install of bench :slight_smile:

It turned out that it is PATH as @vrms mentioned. I add the /usr/local/bin path into secure path in visudo and it works well.
This issue is mentioned by @fromthestone here (Installation on CentOS 8 from instruction not working - #5 by fromthestone)

Yesterday I installed a new bench with sudo pip3 install frappe-bench and add the path. The install went through well until production setup.

I posted a tutorial here:

2 Likes