mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-27 19:16:44 +00:00
fix(contrib): Invoke Path Issues (#8979)
* fix Invoke Path Issues Fixes #8827 * quick exit for docker envs * also exclude rtd enviroment * implement suggested fix for devcontainer * always install
This commit is contained in:
parent
8cc6b9ee65
commit
e75ceb0719
@ -7,6 +7,9 @@ git config --global --add safe.directory /home/inventree
|
||||
python3 -m venv /home/inventree/dev/venv --system-site-packages --upgrade-deps
|
||||
. /home/inventree/dev/venv/bin/activate
|
||||
|
||||
# Ensure the correct invoke is available
|
||||
pip3 install invoke --ignore-installed -U
|
||||
|
||||
# Run initial InvenTree server setup
|
||||
invoke update -s
|
||||
|
||||
|
@ -16,6 +16,12 @@ Only stable / production releases of InvenTree include the frontend panel. This
|
||||
|
||||
Raise an issue if none of these options work.
|
||||
|
||||
#### INVE-E2
|
||||
**Wrong Invoke Path**
|
||||
|
||||
The used invoke executable is the wrong one. InvenTree needs to have
|
||||
You probably have a reference to invoke or a directory with invoke in your PATH variable that is not in InvenTrees virtual environment. You can check this by running `which invoke` and `which python` in your installations base directory and compare the output. If they are not the same, you need to adjust your PATH variable to point to the correct virtual environment before it lists other directories with invoke.
|
||||
|
||||
### INVE-W (InvenTree Warning)
|
||||
Warnings - These are non-critical errors which should be addressed when possible.
|
||||
|
||||
|
28
tasks.py
28
tasks.py
@ -16,6 +16,16 @@ from invoke import Collection, task
|
||||
from invoke.exceptions import UnexpectedExit
|
||||
|
||||
|
||||
def is_docker_environment():
|
||||
"""Check if the InvenTree environment is running in a Docker container."""
|
||||
return os.environ.get('INVENTREE_DOCKER', 'False')
|
||||
|
||||
|
||||
def is_rtd_environment():
|
||||
"""Check if the InvenTree environment is running on ReadTheDocs."""
|
||||
return os.environ.get('READTHEDOCS', 'False') == 'True'
|
||||
|
||||
|
||||
def task_exception_handler(t, v, tb):
|
||||
"""Handle exceptions raised by tasks.
|
||||
|
||||
@ -76,6 +86,21 @@ def checkInvokeVersion():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def chceckInvokePath():
|
||||
"""Check that the path of the used invoke is correct."""
|
||||
if is_docker_environment() or is_rtd_environment():
|
||||
return
|
||||
|
||||
invoke_path = Path(invoke.__file__)
|
||||
loc_path = Path(__file__).parent.resolve()
|
||||
if not invoke_path.is_relative_to(loc_path):
|
||||
error('INVE-E2 - Wrong Invoke Path')
|
||||
error(
|
||||
f'The currently used invoke `{invoke_path}` is not correctly located, ensure you are using the invoke installed in an environment in `{loc_path}` !'
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def checkPythonVersion():
|
||||
"""Check that the installed python version meets minimum requirements.
|
||||
|
||||
@ -101,6 +126,7 @@ def checkPythonVersion():
|
||||
|
||||
if __name__ in ['__main__', 'tasks']:
|
||||
checkInvokeVersion()
|
||||
chceckInvokePath()
|
||||
checkPythonVersion()
|
||||
|
||||
|
||||
@ -629,7 +655,7 @@ def update(
|
||||
# If:
|
||||
# - INVENTREE_DOCKER is set (by the docker image eg.) and not overridden by `--frontend` flag
|
||||
# - `--no-frontend` flag is set
|
||||
if (os.environ.get('INVENTREE_DOCKER', 'False') and not frontend) or no_frontend:
|
||||
if (is_docker_environment() and not frontend) or no_frontend:
|
||||
if no_frontend:
|
||||
info('Skipping frontend update (no_frontend flag set)')
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user