Not able to add an existing custom module to a site

I want to add a custom module which i have created already for another project
So that what i’ve done is i copied module folder and pasted in the apps.
Then performed command bench --site foo.bar1 install-app moduletest.
But it is showing Could not find app "moduletest".
it is resides in frappe-bench/apps directory only.

Please tell me what is the issue in this ?

Hi @rajeeb,

do you have your custom app in a Git repo, e.g. on Github? In this case, the deployment is much easier using the bench get-app command

$ bench get-app https://github.com/yourname/yourapp.git

If you do it manually, check the content of ./sites/apps.txt, this should also contain your app.

You mean frappe-bench/sites/apps.txt ?
But my apps.txt is empty

Nope. Custom app is with me in my local machine.

Yes, the /home/frappe/frappe-bench/sites/apps.txt. It normally contains something like

frappe
erpnext
yourapp

Yes. Got it. Thanks alot

You are welcome!

1 Like

But it didn’t worked for me

i’m attaching error log here

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/commands/site.py", line 169, in install_app
    frappe.init(site=site)
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/__init__.py", line 174, in init
    setup_module_map()
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/__init__.py", line 980, in setup_module_map
    for module in get_module_list(app):
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/__init__.py", line 850, in get_module_list
    return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt"))
  File "/home/rajeeb/frappe-bench/apps/frappe/frappe/__init__.py", line 808, in get_module
    return importlib.import_module(modulename)
  File "/home/rajeeb/frappe-bench/env/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'moduletest'

And your app is /home/frappe/frappe-bench/apps/moduletest ? Is it working in the other instance and copied with all files (including __init__.py)?

@lasalesi Yes. Copied complete folder including all files and it resides in /frappe-bench/apps/moduletest

Maybe there is a workaround when you create a new-app and then paste your app into it.

$ bench new-app moduletest

this will create and link the app. Then copy your files over this files and run

$ bench migrate
$ bench restart