Aakvatech Limited - Rename a Frappe Pilot Bench Safely
Renaming a Frappe Pilot bench is more than renaming a directory. Python virtual environments, systemd services, nginx configuration, and editable app links can all retain the old path.
Renaming a Frappe Pilot Bench Without Breaking Production
Sometimes a Frappe bench has the wrong name for historical reasons.
In our case, a Frappe Pilot bench named:
v15
was actually running Frappe/ERPNext version 16.
The logical cleanup was therefore:
v15 → v16
At first glance, this looks like a straightforward directory rename. In practice, a production Frappe bench contains several components that may reference the bench directory by its absolute filesystem path.
That includes:
- Python virtual environments
- Gunicorn executables
- Python package entry points
- editable app installations
- systemd services
- nginx configuration
- socket.io
- worker processes
- Pilot configuration
The rename eventually worked successfully, but it exposed an important operational lesson:
A Frappe bench directory containing a Python virtual environment should not be considered portable simply because the directory can be moved.
This article documents the complete process, the failures encountered, how they were diagnosed, and the recovery procedure.
Starting point
The original Pilot installation looked conceptually like this:
~/pilot/
└── benches/
├── dev-bench/
└── v15/
Pilot reported:
NAME MODE MANAGER SITES ADDRESS
dev-bench production systemd 0 ...
v15 production systemd 1 ...
However, the v15 bench was actually the Frappe version 16 environment.
The desired state was:
~/pilot/
└── benches/
├── dev-bench/
└── v16/
with commands changing from:
pilot -b v15 ...
to:
pilot -b v16 ...
Why this is more complicated than mv
The obvious command is:
mv ~/pilot/benches/v15 ~/pilot/benches/v16
The filesystem operation itself works.
The problem is that several files inside a Frappe bench may contain references such as:
/home/av/pilot/benches/v15/...
After the directory moves, those paths no longer exist.
Python virtual environments are particularly important here.
Python's own documentation explains that scripts installed inside a virtual environment use shebangs containing the absolute path to the environment's Python interpreter.
For example, our Gunicorn executable contained:
#!/home/av/pilot/benches/v15/env/bin/python
After moving the bench to:
/home/av/pilot/benches/v16/
the Gunicorn file still referred to:
/home/av/pilot/benches/v15/env/bin/python
That old path no longer existed.
This caused the production web process to fail.
Step 1: Rename the Pilot bench
Before changing anything, verify the existing bench:
cd ~/pilot
pilot ls
Then inspect the bench configuration:
grep -n "name =" benches/v15/bench.toml
The relevant configuration may look like:
[bench]
name = "v15"
After stopping/removing the production configuration as appropriate for the installation, rename the directory:
mv ~/pilot/benches/v15 ~/pilot/benches/v16
Then update the bench name in:
~/pilot/benches/v16/bench.toml
from:
[bench]
name = "v15"
to:
[bench]
name = "v16"
Pilot treats bench.toml as the bench's primary configuration source.
Step 2: Rename or reset the Pilot Admin domain
The Pilot Admin hostname is separate from the Frappe site hostname.
For example, after the rename we wanted:
Bench:
v16
Pilot Admin:
myadmin.aakvatech.com
Frappe site:
mysite.aakvatech.com
The Pilot CLI provides a convenient way to change the Admin hostname:
pilot set-admin-domain myadmin.aakvatech.com --tls
Verify:
pilot ls
Our working result became:
NAME MODE MANAGER SITES ADDRESS
dev-bench production systemd 0 https://pilot-dev.aakvatech.com
v16 production systemd 1 https://myadmin.aakvatech.com
At this point the Pilot Admin worked, but the ERPNext site returned:
502 Temporarily unavailable
That distinction was useful.
Because the Admin interface was reachable, nginx and the main Pilot installation were substantially healthy.
The problem was inside the renamed bench's production processes.
Diagnosing the 502 error
The first useful command was:
systemctl --user --failed
The important failures were:
v16-web.service
v16-worker_pool.service
Inspecting the web service gave:
systemctl --user status v16-web.service --no-pager -l
The critical line was:
ExecStart=/home/av/pilot/benches/v16/env/bin/gunicorn ...
but systemd reported:
status=203/EXEC
The journal exposed the actual problem:
journalctl --user -u v16-web.service -n 80 --no-pager
which showed:
Failed to execute /home/av/pilot/benches/v16/env/bin/gunicorn:
No such file or directory
At first this sounds as if gunicorn itself does not exist.
But checking it showed otherwise:
ls -l ~/pilot/benches/v16/env/bin/gunicorn
The executable existed.
The decisive test was:
head -n 1 ~/pilot/benches/v16/env/bin/gunicorn
It returned:
#!/home/av/pilot/benches/v15/env/bin/python
There was the problem.
The executable was present, but its interpreter no longer existed.
Check how widespread the problem is
We searched all executables in the environment:
grep -RIl '^#!.*benches/v15/env' \
~/pilot/benches/v16/env/bin | head -30
Many scripts were affected:
jsonschema
csscombine
weasyprint
rqinfo
ipython3
uvicorn
mcp
dotenv
websockets
...
This demonstrated that manually fixing Gunicorn alone would have been the wrong solution.
The whole virtual environment had been moved.
Correct solution: recreate the virtual environment
Python virtual environments should generally be recreated after their parent directory moves.
Instead of modifying hundreds of generated scripts, preserve the old environment temporarily:
cd ~/pilot/benches/v16
mv env env.old
Then create a new environment:
python3 -m venv env
Install the basic packaging tools:
./env/bin/pip install --upgrade pip setuptools wheel
Then install Frappe:
./env/bin/pip install -e apps/frappe
After doing this, Gunicorn and the Python interpreter paths could be reconstructed correctly.
Verify the Python version before continuing
It is important not to accidentally recreate the environment using a different Python version.
Check the new environment:
cat ~/pilot/benches/v16/env/pyvenv.cfg
and compare it with:
cat ~/pilot/benches/v16/env.old/pyvenv.cfg
In our case both environments used:
Python 3.14.4
so there was no interpreter-version mismatch.
The second problem: app links disappeared
After recreating env, the production services could start, but the site later returned:
Internal Server Error
The reason was important.
Installing:
pip install -e apps/frappe
restored Frappe itself.
But a Frappe bench contains many apps.
For example:
frappe
erpnext
hrms
csf_tz
av_tools
crm
staff_loans
...
These applications were physically present under:
apps/
but were no longer installed into the new Python environment.
Attempting to run Frappe requirements setup exposed this clearly:
ModuleNotFoundError: No module named 'erpnext'
This was not because the ERPNext source directory was missing.
It existed under:
apps/erpnext
The problem was that the new virtual environment did not have ERPNext installed as an editable Python package.
Reinstall all Frappe apps into the environment
Frappe maintains the bench's app list in:
sites/apps.txt
The app links can therefore be recreated systematically.
From the bench root:
cd ~/pilot/benches/v16
while read -r app; do
[ -z "$app" ] && continue
echo "=== Installing $app ==="
./env/bin/pip install -e "apps/$app" || break
done < sites/apps.txt
This reinstalls every app listed in sites/apps.txt as an editable package.
Then verify:
./env/bin/pip list --editable
The locations should point to:
/home/av/pilot/benches/v16/apps/...
rather than the old:
/home/av/pilot/benches/v15/apps/...
Verify Frappe and ERPNext imports
A very useful sanity test is:
./env/bin/python -c \
"import frappe, erpnext; print('frappe + erpnext imports OK')"
The successful result was:
frappe + erpnext imports OK
This confirmed that the core application linkage had been restored.
Reinstall application requirements
After restoring editable applications, Frappe can correctly discover the applications listed in sites/apps.txt.
Because bench_helper expects the sites directory when invoked directly in this way, run:
cd ~/pilot/benches/v16/sites
Then:
/home/av/pilot/benches/v16/env/bin/python \
-m frappe.utils.bench_helper setup requirements
Using the absolute interpreter path also avoids ambiguity around the Python virtual environment.
Regenerate Pilot configuration
A renamed production bench may also contain generated configuration based on the previous bench state.
Pilot provides commands to regenerate this configuration.
From:
cd ~/pilot
run as appropriate:
pilot -b v16 setup config
and:
pilot -b v16 setup nginx
Pilot's production documentation specifically notes that nginx configuration is rendered from bench and site state.
For a full production reconfiguration, Pilot also provides:
pilot -b v16 setup production
Use production setup deliberately because it manages the process manager and nginx integration.
Restart the renamed bench
After restoring dependencies and configuration:
cd ~/pilot
pilot -b v16 restart
Then verify each major process.
Web
systemctl --user status v16-web.service --no-pager -l
Our healthy result showed:
Active: active (running)
with Gunicorn now executing from:
/home/av/pilot/benches/v16/env/bin/python3
Workers
systemctl --user status \
v16-worker_pool.service --no-pager -l
The worker pool was also:
Active: active (running)
Socket.IO
systemctl --user status \
v16-socketio.service --no-pager -l
The healthy process showed:
node /home/av/pilot/benches/v16/apps/frappe/socketio.js
All three critical runtime components were now using the new v16 path.
Verify Pilot
Run:
pilot ls
The final state was:
NAME MODE MANAGER SITES ADDRESS
dev-bench production systemd 0 https://pilot-dev.aakvatech.com
v16 production systemd 1 https://myadmin.aakvatech.com
This confirms that Pilot recognizes the renamed bench as:
v16
rather than:
v15
Verify the ERPNext site
Finally:
curl -I https://mysite.aakvatech.com
During troubleshooting this test helped distinguish three completely different failure classes.
502 Bad Gateway
This meant nginx could not reach the Frappe web process.
In our case:
v16-web.service
was failing because Gunicorn's shebang pointed to the old Python environment.
500 Internal Server Error
This meant Gunicorn was now running, but Frappe failed during application processing.
In our case the recreated Python environment did not yet contain all the editable Frappe applications.
HTTP response from the application
Once the applications, dependencies, services and routing were restored, the site operated normally.
Why the error changed from 502 to 500
This sequence is useful when diagnosing production deployments.
We progressed through:
502
↓
Web process repaired
↓
500
↓
Application environment repaired
↓
Working site
The changing HTTP status was therefore meaningful.
A 502 indicated that the reverse proxy could not successfully communicate with the backend.
Once Gunicorn was running, nginx could reach the backend, so the error changed to 500.
The 500 then exposed the next layer: application imports and Python dependencies.
This layered troubleshooting approach is much more effective than treating every browser error as a generic "site down" problem.
Final working procedure
For future bench-directory renames, the high-level process should be:
1. Inspect existing Pilot configuration
2. Stop/remove production configuration as required
3. Rename the bench directory
4. Update the bench name
5. Update the Pilot Admin domain if required
6. Recreate the Python virtual environment
7. Install Frappe into the environment
8. Reinstall every app from sites/apps.txt
9. Install app requirements
10. Regenerate Pilot configuration
11. Regenerate nginx configuration
12. Reconfigure/restart production services
13. Verify web, workers and socket.io
14. Verify the site over HTTP/HTTPS
15. Delete the old virtualenv only after everything works
Useful diagnostic commands
Pilot state
pilot ls
Failed systemd services
systemctl --user --failed
Web service
systemctl --user status \
v16-web.service --no-pager -l
Worker service
systemctl --user status \
v16-worker_pool.service --no-pager -l
Socket.IO service
systemctl --user status \
v16-socketio.service --no-pager -l
Web journal
journalctl --user \
-u v16-web.service \
-n 80 \
--no-pager
Check an executable's Python interpreter
head -n 1 \
~/pilot/benches/v16/env/bin/gunicorn
Search for old virtualenv shebangs
grep -RIl '^#!.*benches/v15/env' \
~/pilot/benches/v16/env/bin
Find old bench references
grep -R "/home/av/pilot/benches/v15" \
~/pilot/benches/v16/config \
~/.config/systemd/user \
2>/dev/null
Check editable applications
cd ~/pilot/benches/v16
./env/bin/pip list --editable
Test the Python application stack
./env/bin/python -c \
"import frappe, erpnext; print('frappe + erpnext imports OK')"
Do not delete the old environment immediately
A useful safety measure during this operation was:
mv env env.old
rather than:
rm -rf env
Keep:
env.old
until:
- Gunicorn starts
- workers start
- socket.io starts
- application imports work
- the ERPNext site opens
- Pilot recognizes the bench
- nginx routing works
Only then remove it:
rm -rf ~/pilot/benches/v16/env.old
Key lesson: Python virtual environments are not portable
The most important technical lesson from this exercise is not specific to Frappe.
Python virtual environments contain scripts whose shebangs reference the interpreter using an absolute filesystem path.
For example:
#!/home/av/pilot/benches/v15/env/bin/python
Moving the parent directory does not automatically rewrite those paths.
Therefore:
mv v15 v16
cannot be assumed to make:
v15/env
into a valid:
v16/env
environment.
Recreate the virtual environment instead.
This is consistent with Python's own recommendation that moved virtual environments should be recreated at the destination rather than treated as portable directories.
Key lesson: the apps directory and Python app installation are different
Another important Frappe-specific distinction is:
apps/erpnext
existing on disk does not automatically mean:
import erpnext
will work.
The application's source repository and the application's installation into the Python environment are separate concepts.
After recreating a virtualenv, reinstall the bench applications:
pip install -e apps/<app>
For a Frappe bench, sites/apps.txt provides a convenient authoritative list for rebuilding these links.
Recommended improvement for Frappe Pilot
This experience also suggests a useful feature for Pilot itself.
A future native command such as:
pilot rename-bench v15 v16
could potentially orchestrate the operation safely by:
- stopping production services,
- renaming the directory,
- updating
bench.toml, - recreating the virtualenv,
- reinstalling applications,
- reinstalling requirements,
- regenerating nginx,
- regenerating systemd configuration,
- restarting production,
- performing health checks,
- reporting stale references to the old path.
Pilot already models a bench as more than a directory, so treating rename as a lifecycle operation would prevent users from accidentally moving a non-portable Python environment.
Until such an operation exists, a bench rename should be treated as a controlled infrastructure migration rather than a simple filesystem rename.
Final recommendation
If a Frappe Pilot bench needs to be renamed, do not simply rename its directory and assume the environment is portable.
Treat the operation as three separate layers:
Pilot configuration
↓
Runtime environment
↓
Frappe applications
Verify each layer independently.
For the runtime layer, recreate the Python virtual environment.
For the Frappe layer, reinstall every application listed in sites/apps.txt.
For production, regenerate Pilot-managed configuration and verify web, workers, socket.io and nginx individually.
That approach turned what initially appeared to be a broken production bench into a predictable sequence of identifiable failures:
Wrong bench name
↓
Rename
↓
502
↓
Recreate virtualenv
↓
500
↓
Restore editable applications
↓
Working Frappe/ERPNext v16 bench
More importantly, the exercise provides a repeatable procedure for future Frappe Pilot bench renames.
Reference articles and discussions
- Frappe Pilot — Production documentation. Frappe Pilot production documentation
- Frappe Pilot — Command reference. Frappe Pilot command documentation
- Frappe Pilot — Project README and bench configuration overview. Frappe Pilot repository README
- Python documentation —
venvand virtual environment portability. Python venv documentation - Frappe Framework documentation — Bench installation and directory structure. Frappe Bench setup documentation
- Troubleshooting observations and command outputs from the Frappe Pilot
v15→v16production bench rename performed on 13 September 2026.
Aakvatech Limited is a Frappe Gold Partner and ERPNext implementation company headquartered in Dar es Salaam, Tanzania, operating across East Africa and the UAE.
This article was co-created using AI to accelerate drafting, with final insights curated and validated by the author. Any customer, personal, or sensitive data referenced during drafting has been anonymized or masked where applicable. All contributors, reference URLs, tools, and materials used to assist this content curation are credited in the Reference section.
No comments yet. Login to start a new discussion Start a new discussion