Custom Frappe Docker with HRMS App | Tables tabdepartment and tabtask is marked as crashed and should be repaired

Team,
I have been trying out frappe_docker official for the past two weeks.
With the documentations i was able to setup multi bench in single server.

From V14 HRMS is no more part of standard ERPNext modules. I was trying to find if there is a standard image with HRMS. I could not find one.
Then I started to follow the custom app documentation to build an image with HRMS.

I was successful creating a bench and site with erpnext
When i install HRMS app, i constantly get the same error

Installing hrms...
Updating DocTypes for hrms          : [========================================] 100%
Traceback (most recent call last):
  File "/usr/local/bin/patched_bench_helper.py", line 48, in <module>
    raise SystemExit(main())
  File "/usr/local/bin/patched_bench_helper.py", line 43, in main
    frappe.utils.bench_helper.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.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/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.10/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.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 357, in reinstall
    _reinstall(site, admin_password, db_root_username, db_root_password, yes, verbose=context.verbose)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 381, in _reinstall
    _new_site(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 101, in _new_site
    install_app(app, verbose=verbose, set_as_patched=not source_sql, force=False)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 299, in install_app
    frappe.get_attr(after_install)()
  File "/home/frappe/frappe-bench/apps/hrms/hrms/setup.py", line 12, in after_install
    create_custom_fields(get_custom_fields())
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 208, in create_custom_fields
    frappe.db.updatedb(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 365, in updatedb
    db_table.sync()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/schema.py", line 44, in sync
    self.alter()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/schema.py", line 148, in alter
    raise e
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/schema.py", line 132, in alter
    frappe.db.sql(query)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 209, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 148, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 310, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 548, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 1156, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 725, in _read_packet
    packet.raise_for_error()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1194, "Table 'tabtask' is marked as crashed and should be repaired")

Once logged into desk, company initially setup is missing.
when tried to create a new company getting the below error.

Restarted the Mariadb container and it did the magic. The tables were repaired.

Mostly if you install a new site only install erpnext at first. Complete the setup and then install the hrms app.

If you face the tab is marked as crashed error restart the mariadb container.

1 Like

How do you install HRMS once you have ERPNext installed? I have tried
bench --site erp.sitename.com install-app hrms
but it fails with “Could not find app “hrms””

You have to run this command first
bench get-app https://github.com/frappe/hrms

After this, then run
bench --site erp.sitename.com install-app hrms

When I run bench get-app it I just get “Error: Only Frappe framework bench commands are available in container setup.”
I am trying to run within the erpnext backend container. Was hoping to do it without making an custom app container but seems not possible. seeing as this is a standard frappe app I don’t know why this cant be directly available in frappe_docker.

The official frappe Docker only ship Frappe and ERPNext in its image.

If you need HRMS you need to build your own custom image using the steps in the official frappe docker documentation.

I have built a custom image with HRMS app. You can refer to this repo for reference

You can refer to the post for more information frappe docker with custom app error