frappe / helm

Helm Chart Repository for Frappe/ERPNext
https://helm.erpnext.com
MIT License
138 stars 120 forks source link

Error /bin/sh: 1: ../env/bin/python: not found when execute bench --site command migrate before starting the custom app #183

Closed dungtc closed 1 year ago

dungtc commented 1 year ago

Description of the issue

Build custom app and start to run bench --site my_site migrate before running the image I got this error

Reason: because the WORKDIR is "/home/frappe/frappe-bench" and the bench bin_path was configured with absolute path "../env/bin" in https://github.com/frappe/frappe/blob/develop/frappe/commands/utils.py#L565C15-L565C16

The requirement path must be "/home/frappe/frappe-bench/sites"

Expected result

Change the WORKDIR of custom app from "/home/frappe/frappe-bench" to "/home/frappe/frappe-bench/sites" to run bench commands before starting the app

Stacktrace / full error message if available

Run bench --site my_site migrate before starting the custom app

"/bin/sh: 1: ../env/bin/python: not found"
revant commented 1 year ago

Please add a failing test.

https://github.com/frappe/frappe_docker/actions/runs/5617087162/job/15220580513

You are using old images? migrate to new ones: https://github.com/frappe/frappe_docker/blob/main/docs/migrate-from-multi-image-setup.md

revant commented 1 year ago

Migrate works for me locally and bench commands work on github actions / tests.

https://github.com/frappe/frappe_docker/assets/1040161/c17fd56c-e515-411f-8e3c-9f728c68ff90

dungtc commented 1 year ago

Ops.. I forgot to update CMD option "--chdir=/home/frappe/frappe-bench/sites" Tks.

dungtc commented 1 year ago

Hi @revant i still got this error when i run worker on erpnext helm chart.

Stacktrace

File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/scheduler.py", line 206, in start_worker
    start_worker(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 223, in start_worker
    with frappe.init_site():
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 341, in __enter__
    init(self.site)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 248, in init
    setup_module_map()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1538, in setup_module_map
    for module in get_module_list(app):
                  ^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1378, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
                                                       ^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1327, in get_module
    return importlib.import_module(modulename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'erpnext'
revant commented 1 year ago

https://github.com/frappe/helm/actions/runs/5419865585/job/14677512184

These tests also test bench migrate

https://github.com/frappe/helm/blob/4986de9a91441b042b0454c1aff46e9469f26771/tests/script.sh#L71

dungtc commented 1 year ago

Thank @revant I just update the stacktrace when start the worker, it doesn't find the erpnext module on frappe init_site, do you know why?

dungtc commented 1 year ago

Dear @revant , please help. Thanks My current version is v14.30.0 that includes Frappe, ERPNext and my custom app.

revant commented 1 year ago

Give me access to apps and container registry to push image

dungtc commented 1 year ago

Give me access to apps and container registry to push image

I use your docker image in here https://github.com/frappe/frappe_docker/blob/main/images/production/Containerfile and run with erpnext helm chart.

My current version is v14.30.0 that includes Frappe, ERPNext. When the run the deployment of worker or migration job I got this error ModuleNotFoundError: No module named 'erpnext' with this stacktrace.

I've checked my docker image, it already have erpnext, payments, frappe in apps folder and still don't know why.

image
revant commented 1 year ago

make sure you also have it in sites/apps.txt. If it's not present add using ls -1 apps > sites/apps.txt.

If you are using CRI-O consider this: https://github.com/frappe/helm/issues/181

revant commented 1 year ago

Make sure you use correct apps.json

https://github.com/frappe/frappe_docker/blob/main/docs/custom-apps.md